Documentation
¶
Index ¶
- func CreateBranch(repoPath, branchName, fromRef string) error
- func CreateWorktree(repoPath, worktreePath, branchName string) error
- func DeleteBranch(repoPath, branchName string) error
- func DirtyFiles(dir string) ([]string, error)
- func DiscoverDefaultBranch(repoPath string) (string, error)
- func DiscoverDefaultBranchOrHEAD(repoPath string) (string, error)
- func DiscoverGitHubUsername(ctx context.Context, repoPath string) (string, error)
- func FetchOrigin(repoPath string) error
- func FetchOriginContext(ctx context.Context, repoPath string) error
- func FetchRemote(ctx context.Context, worktreePath string) error
- func HasRemote(dir string, name string) bool
- func HasUncommittedChanges(dir string) (bool, error)
- func IsInsideGitRepo(dir string) bool
- func IsRegisteredWorktree(repoPath, worktreePath string) bool
- func ListMaintenanceRepos(ctx context.Context) ([]string, error)
- func ParseGitHubUsername(remoteURL string) (string, bool)
- func PruneWorktrees(repoPath string) error
- func RefExists(dir string, ref string) bool
- func RemoveWorktree(repoPath, worktreePath string) error
- func RepoRootFromWorktree(worktreePath string) (string, error)
- func RepoRootPath(dir string) (string, error)
- func Run(dir string, args ...string) (string, string, error)
- func RunCheck(dir string, args ...string) bool
- func RunContext(ctx context.Context, dir string, args ...string) (string, string, error)
- func RunContextEnv(ctx context.Context, dir string, env []string, args ...string) (string, string, error)
- func RunOutput(dir string, args ...string) (string, error)
- func RunOutputContext(ctx context.Context, dir string, args ...string) (string, error)
- func SetupSession(ctx context.Context, repoPath, worktreePath, branchName, baseBranch string, ...) error
- func TeardownSession(repoPath, worktreePath, branchName string) error
- func UnpushedCommitCount(worktreePath, baseBranch string) (int, error)
- func UnpushedCommitSummaries(worktreePath, baseBranch string) ([]string, error)
- func WorktreeGitDirs(worktreePath string) (gitDir, commonDir string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBranch ¶
func CreateWorktree ¶
func DeleteBranch ¶
func DirtyFiles ¶ added in v0.3.0
func DiscoverDefaultBranch ¶
func DiscoverDefaultBranchOrHEAD ¶ added in v0.19.0
func DiscoverGitHubUsername ¶
func FetchOrigin ¶
func FetchOriginContext ¶ added in v0.30.0
func FetchRemote ¶ added in v0.66.12
FetchRemote updates remote tracking refs from origin. It prunes deleted remote branches and never rewrites local branches. It is best-effort: callers use it to keep base-branch refs fresh for the diverged-from-base count and should tolerate failures (offline, no remote).
func HasUncommittedChanges ¶
func IsInsideGitRepo ¶
func IsRegisteredWorktree ¶ added in v0.66.2
IsRegisteredWorktree reports whether worktreePath is registered as a worktree of the repo at repoPath. It matches even a worktree whose .git link is broken, since git still lists a stale (prunable) registration — that registration is the signal graith owns the path and may remove it during teardown (#741). It returns false when the repo is unreachable or the path is not a registered worktree (an unrelated directory, an independent repo, or an already-orphaned entry), so teardown never deletes a directory graith doesn't own. Detection is based on the stable `--porcelain` listing rather than git's error text, so it is independent of git's locale and message wording.
func ListMaintenanceRepos ¶ added in v0.42.0
func ParseGitHubUsername ¶
func PruneWorktrees ¶ added in v0.29.0
func RemoveWorktree ¶
func RepoRootFromWorktree ¶ added in v0.29.0
func RepoRootPath ¶
func RunContext ¶ added in v0.30.0
func RunContextEnv ¶ added in v0.42.0
func RunOutputContext ¶ added in v0.30.0
func SetupSession ¶
func TeardownSession ¶
TeardownSession removes a session's worktree and branch. It is idempotent: a missing or broken worktree is treated as already-removed and never blocks dropping the session. `git worktree remove --force` fails with exit 128 when the directory is gone or its .git link is broken; when git still lists the path as a registered worktree of this repo (as it does for a broken link) we remove the directory directly and prune the stale registration so a broken worktree can't wedge delete forever (#741). A failure where the path is not a registered worktree — an unreachable/invalid source repo, or a stale path pointing somewhere graith doesn't own — is surfaced so the session is kept for retry rather than dropped (and nothing unowned is deleted).
func UnpushedCommitCount ¶
UnpushedCommitCount returns the number of commits on HEAD that have not been pushed to the remote.
It compares against the current branch's remote tracking ref (origin/<branch>) when that ref exists. This answers "have I pushed my commits?" and reflects real push state without any network I/O: `git push` updates the local tracking ref, and after a branch's PR is merged the tracking ref still points at the pushed tip, so the count correctly reads 0 (no false "N ahead of main"). See issue #197.
When the branch has never been pushed (no tracking ref) it falls back to counting commits ahead of the base branch — everything that would be pushed. The base ref itself may be stale without a fetch; a periodic fetch in the daemon keeps it reasonably fresh.
func UnpushedCommitSummaries ¶ added in v0.3.0
func WorktreeGitDirs ¶ added in v0.19.0
Types ¶
This section is empty.