Documentation
¶
Overview ¶
Package gitfacts reads cheap git facts straight from the files of a repository: HEAD, config, the gitdir pointer of a linked worktree and the registrations under worktrees/. It never runs git and never walks a tree, which is what makes it safe to call per project on every request; the package that runs the binary is internal/git, and the two deliberately do not meet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OriginName ¶
OriginName is the short display form of a remote url: host and path, no scheme, no user, no .git suffix.
func OriginWebURL ¶
OriginWebURL turns a remote url into the https address a browser can open, or "" when the url has no such form.
func PruneWorktreeRegistration ¶
func PruneWorktreeRegistration(dir string)
PruneWorktreeRegistration removes the metadata directory a linked worktree stands registered under in its main repository, what a later `git worktree prune` would do; without it the main keeps the worktree's branch checked out and refuses it. The registration's gitdir file is read back first, only an entry that names this very worktree is taken; any doubt, a dangling pointer included, leaves the main untouched. The one write of this package, and a file operation like everything else in it.
Types ¶
type Info ¶
type Info struct {
Repo bool
Branch string // checked-out branch, or a short hash on a detached HEAD
Origin string // the origin remote's url as written in the config
Worktree bool // dir is a linked worktree (.git is a gitdir pointer file)
WorktreeMain string // main repository path, "" when it cannot be derived
WorktreePaths []string // worktree directories registered in this repository
}
Info is what the file reads answer about one directory.