Documentation
¶
Overview ¶
Package git creates opt-in commits of an applied change set. It is deliberately minimal and hardened: a commit stages ONLY the caller-supplied paths (never `git add -A`), runs with repository hooks disabled, and executes in a sanitized environment so a git hook, credential helper, or editor can never observe the daemon's privileged environment or provider API keys (§M7).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BinPath = "git"
BinPath is the path to the git binary used by Commit. It is a package-level variable so tests can substitute a fake git (mirroring the executor's dockerPath override). Defaults to "git", resolved via PATH.
Functions ¶
func Commit ¶
Commit stages the given workspace-relative paths (adds, modifications, and deletions) and creates one commit whose subject is message. It returns the new commit's SHA.
Behavior:
- If workTree is not a git repository (workTree/.git missing), it returns ("", nil) — a non-repo is a silent no-op, not an error.
- If there is nothing to commit (the staged diff is empty), it returns ("", nil).
- Only the given paths are staged; the commit never uses `git add -A`.
- Repository hooks are disabled (core.hooksPath points at an empty temp dir), so `git commit` cannot execute arbitrary hook code under the daemon's environment.
- The git process runs with a sanitized environment (PATH/HOME/LANG plus GIT_TERMINAL_PROMPT=0), so inherited GIT_* variables and provider API keys are dropped.
Any real git failure (missing binary, identity not configured, lock held, etc.) is returned as an error; the caller treats it as non-fatal.
Types ¶
This section is empty.