gitutil

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTracked

func IsTracked(repoRoot, path string) (bool, error)

IsTracked reports whether the file at path is tracked by git in the given repo root. Returns (false, nil) if the file does not exist. Returns (false, error) on git errors (fail-closed).

func MainWorktreeRoot added in v0.9.0

func MainWorktreeRoot(dir string) string

MainWorktreeRoot returns the root of the main worktree when dir is inside a linked git worktree. Returns "" otherwise — main worktree itself, non-git directory, bare repo, or anywhere the detection is ambiguous. Never errors.

func Output

func Output(dir string, args ...string) (string, error)

Output runs `git <args...>` in the given directory and returns trimmed stdout.

func RepoRoot

func RepoRoot(dir string) (string, error)

RepoRoot returns the top-level directory of the git repository containing dir.

Types

type Context added in v0.6.0

type Context struct {
	Cwd                 string `json:"cwd"`
	RepoRoot            string `json:"repo_root,omitempty"`
	GitDir              string `json:"git_dir,omitempty"`
	GitCommonDir        string `json:"git_common_dir,omitempty"`
	PrimaryCheckoutRoot string `json:"primary_checkout_root,omitempty"`
	BranchName          string `json:"branch_name,omitempty"`
	IsWorktree          bool   `json:"is_worktree"`
}

Context is the cwd-derived git information ccgate exposes to the LLM. Targets stitch this onto their own per-tool payload (Claude adds referenced_paths, Codex forwards tool_input verbatim).

func BuildContext added in v0.6.0

func BuildContext(cwd string) Context

BuildContext gathers git repository context for the given working directory. Each git lookup is best-effort: the function never errors out — fields stay empty when the corresponding `git` command fails or `cwd` is not in a git repo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL