Documentation
¶
Overview ¶
Package gitutil provides the minimal git introspection the context-sync configurator needs: repo root, origin remote, current branch, HEAD sha, plus an idempotent .gitignore helper anchored at the repo root (DX-10).
It shells out to the `git` binary (already a hard dependency of the workflow) and degrades gracefully: every function returns a usable zero value when not in a repo or when git is unavailable, so callers never crash a hook.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureGitignore ¶
EnsureGitignore makes sure pattern appears in <root>/.gitignore. It reads the file (creating it if absent), checks for an exact-line match, and appends the pattern atomically only if missing. Returns true if it added the pattern.
func Slug ¶ added in v0.6.2
Slug normalizes a git remote URL to a canonical "owner/repo" project slug (FR-7): the last two path segments, with any ".git" suffix and surrounding noise stripped. It collapses the common remote shapes to the same value:
git@github.com:owner/repo.git → owner/repo https://github.com/owner/repo.git → owner/repo https://github.com/owner/repo → owner/repo ssh://git@host:22/owner/repo.git → owner/repo
Returns "" when no usable owner/repo can be derived (callers fall back to the repo-root basename for the "Local / no remote" bucket, FR-10).