Documentation
¶
Overview ¶
Package gitops wraps the git and gh commands needed to read the default branch of a repo and to land a change on it — pushing directly when allowed, or opening an auto-merge PR when the branch is protected. The flow mirrors the proven all-repos-codegrapher.sh script.
Index ¶
- func Clone(cloneURL, dest string) error
- func DefaultBranch(repoPath string) (string, error)
- func Fetch(repoPath string) error
- func LocalState(repoPath string) (dirty bool, reason string, err error)
- func Pull(repoPath string) error
- func ShowFile(repoPath, ref, path string) (content string, ok bool, err error)
- func WorktreeChanged(dir string) (bool, error)
- type LandOptions
- type Mutator
- type Outcome
- type RepoStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBranch ¶
DefaultBranch returns the remote's default branch (e.g. "main"). It first refreshes origin/HEAD from the remote, because a local clone's cached origin/HEAD can be stale (e.g. the repo was renamed master -> main after the clone was made), which would otherwise yield the wrong branch.
func LocalState ¶
LocalState reports whether repoPath has uncommitted changes (including untracked files) or local commits not present on any remote. The reason string names the first condition found.
func ShowFile ¶
ShowFile returns the contents of path at ref (e.g. "origin/main"), and a false ok when the file does not exist at that ref.
func WorktreeChanged ¶
WorktreeChanged reports whether the worktree at dir has any uncommitted changes (tracked edits or untracked files), via `git status --porcelain`.
Types ¶
type LandOptions ¶
type LandOptions struct {
DefaultBranch string
CommitMessage string
PRBranch string
PRTitle string
PRBody string
}
LandOptions configures how a change is committed and pushed.
type Mutator ¶
Mutator edits files inside the worktree and reports whether it changed anything along with a human-readable detail.
type Outcome ¶
Outcome describes what Land did.
func Land ¶
func Land(repoPath string, opt LandOptions, mutate Mutator) (Outcome, error)
Land fetches, creates a detached worktree at origin/<default>, runs mutate, and — if it changed files — commits and pushes to the default branch, falling back to a PR with auto-merge when the push is rejected (protected branch).
type RepoStatus ¶
type RepoStatus struct {
Modified []string // tracked files with changes
Untracked []string // untracked files
Conflicted []string // merge-conflict paths
Unpushed []string // `git log --branches --not --remotes --oneline` lines
Stashed []string // `git stash list` lines
}
RepoStatus is git working-tree/history state relevant to sync decisions and to reporting why a repo needs attention.
func Status ¶
func Status(repoPath string) (RepoStatus, error)
Status reads repoPath's working tree, stash, and unpushed-commit state.
func (RepoStatus) Dirty ¶
func (s RepoStatus) Dirty() bool
Dirty reports whether s represents any state — working tree, stash, or unpushed commits — that should block automatically removing an archived repo's local clone.
func (RepoStatus) Summary ¶
func (s RepoStatus) Summary() string
Summary renders a short human-readable description of s, e.g. "3 modified files, 1 untracked file". Empty when nothing is set.
func (RepoStatus) WorkingTreeDirty ¶
func (s RepoStatus) WorkingTreeDirty() bool
WorkingTreeDirty reports whether the working tree itself has changes (modified, untracked, or conflicted files) — the check used to decide whether it is safe to `git pull`.