Skip to main content

Module git

Module git 

Source
Expand description

The git engine: read-only status/branches plus checkout/create-branch/ commit-push, all shelling git against a caller-supplied cwd. This is the “reads/runs what-is, no policy” half of the workspace primitive; the axum HTTP handlers that call these functions stay in Core (server wiring), as do the pure-filesystem /api/workspace/{new-folder,list} handlers (they shell no git — node-fs, kernel-owned).

Structs§

CommitPushOutcome
Shaped POST /api/git/commit-push result: what the action actually did.
GitBranches
Shaped GET /api/git/branches result: local branches plus the current one.
GitState
Shaped GET /api/git/status result: the working-tree state of a repo cwd.

Functions§

checkout_branch
Switch cwd to an existing local branch via git switch.
create_branch
Create a new branch off the current HEAD and switch to it (git switch -c).
list_branches
List local branches plus the currently checked-out one for cwd. Returns is_repo:false when cwd is not a git repository.
query_git_state
Compute the working-tree state for cwd (branch, ahead/behind, dirty, diff totals). Returns is_repo:false when cwd is not a git repository.
run_git_action
Commit, push, or do both for cwd. action is one of commit, commit-push, or push (validated by the caller). When include_unstaged is set, stages everything before committing. Returns the raw git stderr on any failure.