Repository navigation
feat: add source-control status, push and pull commands - #22
Conversation
Wraps the public API's /source-control endpoints. Push takes explicit --workflow/--item targets; 409 responses list the conflicting items and 403 responses name the missing API key scope.
|
/gemini review |
|
🔏 Readiness attested — the Readiness summaryPR Readiness Check (#22, 3b68d6b) |
|
🔏 Readiness attested — the Readiness summaryPR Readiness Check (#22, d48e6e0) |
Summary
Adds
n8nctl source-control(aliassc) for n8n's Git-backed source control, using the public API endpoints documented at https://docs.n8n.io/connect/n8n-api/source-control:status [--direction push|pull]callsGET /source-control/statuspush -m <msg> --workflow <id>... --item <type>:<id>... [--force]callsPOST /source-control/pushpull [--force] [--auto-publish none|all|published]callsPOST /source-control/pullDesign notes:
request()now returns an*APIErrorthat keeps the status code and raw body. TheError()text is unchanged. The source-control calls use the body for 409 responses: push returns{message, conflicts}and pull returns a bare array. In both cases the CLI lists the conflicting items and points at--force; with--jsonthe error and the conflict list go to stdout as one JSON object.sourceControl:read,:pushor:pull).{}when no flags are set, because the endpoint requires one.Testing
go test -race ./...passes. httptest coverage includes the push body shape,force, the empty{}pull body, pull's bare-array response, both 409 shapes, the 403 scope hint for all three calls, and unchangedAPIErrormessages.sc statusreturnsAPI error (403): Forbidden (the API key needs the sourceControl:read scope ...). The current stage key only hassourceControl:pull(checked viaGET /discover). Flag validation also checked: bad--direction, missing-m, no items, unknown--itemtype, bad--auto-publish.