Documentation
¶
Overview ¶
Package gitrepo implements the coder's git port by shelling out to the git binary — always argv, never a shell string. Author and committer identity are left alone: attribution is a single sanitized "Assisted-by: <model> via Strument" trailer on auto-commits.
Index ¶
- func Trailer(modelName string) string
- type Commit
- type Repo
- func (r *Repo) ChangedInHead() ([]string, error)
- func (r *Repo) ChangedInRange(rev string) ([]string, error)
- func (r *Repo) CheckoutFileFrom(rev, rel string) error
- func (r *Repo) Commit(fnames []string, context, want string, attributed bool) (hash, message string, ok bool, err error)
- func (r *Repo) CurrentBranch() string
- func (r *Repo) DiffWorktree(base string) (string, error)
- func (r *Repo) GitIgnored(rel string) bool
- func (r *Repo) HeadInfo() (sha, short, subject string, parents int, err error)
- func (r *Repo) HeadSHA() string
- func (r *Repo) InCommit(commitish, rel string) bool
- func (r *Repo) IsDirty(rel string) bool
- func (r *Repo) LastCommits(n int) ([]Commit, error)
- func (r *Repo) PathInRepo(rel string) bool
- func (r *Repo) ResetSoft(rev string) error
- func (r *Repo) RevParse(rev string) (string, error)
- func (r *Repo) Root() string
- func (r *Repo) TrackedFiles() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Repo ¶
type Repo struct {
// Trailer is appended to attributed commits via `git commit
// --trailer`; build it with Trailer() so the model name is sanitized.
CommitTrailer string
// Message generates a commit message from staged diffs and chat
// context (the side-model call); nil or an empty result falls
// back to aider's "(no commit message provided)".
Message func(diffs, context string) string
// Sign, when non-empty, is the `git commit` signing flag passed
// through as its own argv: "-S" to sign with the default key, or
// "-S<keyid>" to pick one (git_sign = true / "keyid"). Empty means
// unsigned.
Sign string
// contains filtered or unexported fields
}
Repo is a discovered git repository.
func Discover ¶
Discover finds the repository containing dir, or returns an error when dir is not inside a git worktree (or git is not installed).
func (*Repo) ChangedInHead ¶
ChangedInHead lists the files HEAD changed relative to its first parent.
func (*Repo) ChangedInRange ¶
ChangedInRange lists the files changed between rev and HEAD — what /squash needs to re-stage after folding several commits back into the index.
func (*Repo) CheckoutFileFrom ¶
CheckoutFileFrom restores rel from the given revision into the worktree and index.
func (*Repo) Commit ¶
func (r *Repo) Commit(fnames []string, context, want string, attributed bool) (hash, message string, ok bool, err error)
Commit stages fnames and commits them. attributed adds the trailer (auto-commits of model edits); dirty commits stay unattributed. ok=false means there was nothing to commit. GIT_AUTHOR_* and GIT_COMMITTER_* are never overridden; hooks run normally.
want is the message to use. Empty means generate one from the staged diff through the Message hook, which is the automatic path; a non-empty one is used verbatim, for the commit tool where the model writes its own.
func (*Repo) CurrentBranch ¶
CurrentBranch returns the checked-out branch name ("" when detached).
func (*Repo) DiffWorktree ¶
DiffWorktree returns `git diff <base>`: the changes from base to the current worktree (the /diff view).
func (*Repo) GitIgnored ¶
GitIgnored reports whether rel matches the ignore rules.
func (*Repo) HeadInfo ¶
HeadInfo describes HEAD for /undo: full and short hashes, the subject line, and the parent count.
func (*Repo) IsDirty ¶
IsDirty reports whether rel has staged or unstaged changes against HEAD (untracked files are not dirty, matching GitPython's is_dirty).
func (*Repo) LastCommits ¶
LastCommits returns the n most recent commits, newest first. It returns fewer than n only when the branch is shorter than that.
func (*Repo) PathInRepo ¶
PathInRepo reports whether rel is tracked.
func (*Repo) TrackedFiles ¶
TrackedFiles returns the tracked files, repo-root-relative.