Documentation
¶
Overview ¶
Package git provides best-effort discovery of git metadata for a project directory. Everything here is optional: if git is not installed or the directory is not a repository, the functions return an empty Info and no error, so callers can include git metadata when available without failing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
Clone clones remote into dir and, when commit is non-empty, checks it out. It is only ever invoked when the user explicitly opts in (e.g. --clone), so it surfaces errors rather than swallowing them like Discover does.
func IsRepo ¶
IsRepo reports whether dir is inside a git working tree. It is best-effort: a missing git binary or any failure yields false.
func Push ¶
Push pushes the current branch of the repo at dir to its remote. It is only invoked when the user explicitly opts in (--git-push), so it surfaces errors rather than swallowing them. It is deliberately conservative: it never force-pushes, never pushes tags, and never creates a remote — it runs a plain `git push <remote> <branch>`, so a diverged remote is rejected as a non-fast-forward rather than overwritten. It returns the remote name and branch that were pushed.
Types ¶
type Info ¶
type Info struct {
Branch string `json:"branch,omitempty"`
CommitSHA string `json:"commit_sha,omitempty"`
RemoteURL string `json:"remote_url,omitempty"`
// Dirty reports that the working tree had uncommitted changes when the
// bundle was exported, so HEAD does not capture the exact state.
Dirty bool `json:"dirty,omitempty"`
// Unpushed reports that the HEAD commit is not reachable from any
// remote-tracking branch, so the other machine cannot fetch it yet.
Unpushed bool `json:"unpushed,omitempty"`
}
Info holds the git facts we record in a bundle manifest.