Documentation
¶
Index ¶
- func ProviderFromRemoteURL(remoteURL string) string
- type FileStat
- type HookInstallOptions
- type Repo
- func (r *Repo) ChangedFilesForCommit(ctx context.Context, hash string) ([]string, error)
- func (r *Repo) CommitSubject(ctx context.Context, commitHash string) (string, error)
- func (r *Repo) CommitSubjectsBetween(ctx context.Context, base, head string, limit int) ([]string, error)
- func (r *Repo) CurrentBranch(ctx context.Context) (string, error)
- func (r *Repo) DefaultBaseRef(ctx context.Context) (string, error)
- func (r *Repo) DiffAll(ctx context.Context) ([]byte, error)
- func (r *Repo) DiffBetween(ctx context.Context, base, head string) ([]byte, error)
- func (r *Repo) DiffCached(ctx context.Context) ([]byte, error)
- func (r *Repo) DiffForCommit(ctx context.Context, hash string) ([]byte, error)
- func (r *Repo) DiffStatForCommit(ctx context.Context, hash string) ([]FileStat, error)
- func (r *Repo) HeadCommitHash(ctx context.Context) (string, error)
- func (r *Repo) HooksDir(ctx context.Context) (string, error)
- func (r *Repo) InstallSemanticaHook(ctx context.Context, opts HookInstallOptions) error
- func (r *Repo) IsDirty(ctx context.Context) (bool, error)
- func (r *Repo) ListFilesFromGit(ctx context.Context) ([]string, error)
- func (r *Repo) MergeBase(ctx context.Context, a, b string) (string, error)
- func (r *Repo) ReadFile(relPath string) ([]byte, error)
- func (r *Repo) RemoteURL(ctx context.Context) (string, error)
- func (r *Repo) RemoveFile(relPath string) error
- func (r *Repo) ResolveRef(ctx context.Context, ref string) (string, error)
- func (r *Repo) RestoreFile(relPath string, content []byte, mode os.FileMode, isSymlink bool, ...) error
- func (r *Repo) Root() string
- func (r *Repo) WriteFile(relPath string, b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProviderFromRemoteURL ¶
ProviderFromRemoteURL returns the hosting provider based on the remote URL hostname. Returns "github", "gitlab", or "unknown".
Types ¶
type HookInstallOptions ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
func (*Repo) ChangedFilesForCommit ¶
ChangedFilesForCommit returns the repo-relative paths (forward slashes) of files changed by the given commit. Uses git diff-tree, the canonical plumbing command for listing files touched by a commit.
func (*Repo) CommitSubject ¶
func (*Repo) CommitSubjectsBetween ¶
func (r *Repo) CommitSubjectsBetween(ctx context.Context, base, head string, limit int) ([]string, error)
CommitSubjectsBetween returns commit subject lines (no hashes) for commits reachable from head but not from base, newest first, capped at limit.
func (*Repo) CurrentBranch ¶
CurrentBranch returns the current branch name (e.g. "main", "feature-x"). Returns "HEAD" for detached HEAD state.
func (*Repo) DefaultBaseRef ¶
DefaultBaseRef returns the best-guess default branch ref for the repository. Resolution order: refs/remotes/origin/HEAD, origin/main, origin/master, main, master.
func (*Repo) DiffAll ¶
DiffAll returns a unified diff of all uncommitted changes: staged, unstaged, and untracked files. Untracked files are represented as new-file diffs so the LLM sees their full content.
func (*Repo) DiffBetween ¶
DiffBetween returns the unified diff between two refs (three-dot: from merge-base of a and b to b). This shows only changes introduced on the feature branch, not upstream drift.
func (*Repo) DiffCached ¶
DiffCached returns the unified diff of staged changes against HEAD. Used by the commit-msg hook to compute AI attribution before the commit is finalized (the commit hash doesn't exist yet at that point).
func (*Repo) DiffForCommit ¶
func (*Repo) DiffStatForCommit ¶
DiffStatForCommit returns per-file added/deleted line counts for the given commit using git diff --numstat. Binary files are included with 0/0 counts.
func (*Repo) InstallSemanticaHook ¶
func (r *Repo) InstallSemanticaHook(ctx context.Context, opts HookInstallOptions) error
func (*Repo) IsDirty ¶
IsDirty returns true if the working tree has any changes: -modified, staged, deleted, untracked
func (*Repo) ListFilesFromGit ¶
func (*Repo) RemoveFile ¶
func (*Repo) ResolveRef ¶
ResolveRef resolves a git ref (HEAD, branch name, tag, commit prefix) to a full commit hash. Returns an error if the ref is not valid.
func (*Repo) RestoreFile ¶
func (r *Repo) RestoreFile(relPath string, content []byte, mode os.FileMode, isSymlink bool, linkTarget string) error
RestoreFile restores a file from a checkpoint manifest. It handles both regular files (with correct mode bits) and symlinks. For backward compatibility, if mode is 0 it defaults to 0644.