Skip to content

Git component reference ​

This page lists every field and option. The overview shows what it does and a first example.

The git component runs version-control operations (status, diff, log, show, branch, remote, add, commit, checkout, init, clone, push, pull) and returns parsed results: file lists, commit objects, branch lists. It is a YAML component from the components asset set. Call it with a component: resource, no install step. The operations are the kdeps API's git_ops tool. The component only POSTs the arguments.

Where it runs ​

The workflow runs this resource as a step.

Requirements ​

git and python3 (or python) on PATH. The operations are the git_ops tool. This tool is a python: block in tools/git_ops.yaml. The kdeps API serves it in the kdeps process. The component makes one call and returns the result.

Basic usage ​

yaml
# resources/status.yaml
actionId: gitStatus
name: Check Repository Status
component:
  name: git                    # from the components asset set; a components/git/ of your own wins
  with:
    operation: status
    workingDir: /path/to/repo  # default: the current directory
yaml
# resources/commit.yaml
actionId: gitCommit
name: Commit Changes
flow:
  requires: [gitStatus]
component:
  name: git
  with:
    operation: commit
    workingDir: /path/to/repo
    message: "feat: add new feature"
    dryRun: true               # report what would happen, change nothing

Inputs ​

InputOperationDescription
operationallstatus, diff, log, show, branch, remote, add, commit, checkout, init, clone, push, pull (required)
workingDirallRepository directory; for clone, the target directory
pathsadd, checkout, diff, logSpace-separated paths (add defaults to .)
messagecommitCommit message (required for commit)
branchcheckout, push, pullBranch name
urlcloneRepository URL
remotepush, pullRemote name (default origin)
argsshowExtra space-separated git arguments, e.g. HEAD~1
maxCountlogCommits to list (default 10)
dryRunadd, commit, checkout, init, clone, push, pullPreview without modifying

Component inputs are strings. For this reason, spaces separate the items in paths and args. Put a path with spaces in quotes, as in a shell: paths: "'my file.txt' src/".

Output ​

Every result has success: true plus the operation's fields. A failing git command fails the resource with git's error.

json
{"success": true, "branch": "main", "staged": ["file1.go"], "unstaged": ["file2.go"], "untracked": ["new.txt"], "conflicts": []}
OperationFields
statusbranch, staged, unstaged, untracked, conflicts
diffdiff, additions, deletions
logcommits (hash, author, email, date, message), count
showoutput
branchbranches (name, current, remote), current, count
remoteremotes (name, url, type), count
add / commit / checkout / init / clone / push / pullstaged / committed+message / switched+branch+paths / initialized+path / cloned+url / pushed or pulled+remote+branch; dryRun: true when previewing
yaml
flow:
  # resources/report.yaml
  requires: [gitStatus]
apiResponse:
  success: true
  response:
    branch: "{{ output('gitStatus').branch }}"
    untracked: "{{ output('gitStatus').untracked }}"

Best practices ​

  1. Always set workingDir - then it is clear which repository the operation uses
  2. Use dryRun on write operations - verify before committing, pushing, or checking out
  3. Use status before add to see the changes that add stages
  4. Set maxCount on log to keep output bounded

How it is built ​

text
component: git -> POST /apis/tools.kdeps.io/v1/tools/git_ops/call -> {success, ...operation fields}

One httpClient POST carrying the ten inputs to the git_ops tool, then an interface.output that decodes the tool's JSON body. The tool runs git with GIT_PAGER=cat and GIT_TERMINAL_PROMPT=0 and parses the output into the same fields. A command that fails returns git <operation> failed: exit status N with the stderr of git. Before git runs, kdeps checks workingDir against KDEPS_WORKSPACE_ROOT. kdeps permits paths under ~/.kdeps and /tmp. kdeps stops one call after 5 minutes.

To change an input default, copy components/git/ into your project. To change the operations, copy tools/git_ops.yaml to ~/.kdeps/tools/.

See also ​

kdeps has the Apache 2.0 License.