git

package
v0.4.2-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchExists added in v0.2.0

func BranchExists(remote, name string) (bool, error)

BranchExists reports whether the remote-tracking ref refs/remotes/<remote>/<name> exists by running "git rev-parse --verify". An exit code of 0 means the ref exists, a non-zero exit code means it does not, and an execution failure is returned as an error.

This checks remote-tracking refs, so the remote must have been fetched first. A shallow or partial fetch that omits the branch will cause this to report false.

func CommitAndPush

func CommitAndPush(filePath, message string) error

CommitAndPush stages a file, commits with the given message, and pushes to origin.

func CommitAndPushWithRetry added in v0.2.0

func CommitAndPushWithRetry(filePath, message string) error

CommitAndPushWithRetry stages filePath, commits it with message, and pushes to the current branch's upstream, retrying the push up to three times behind a pull --rebase. A "nothing to commit" state is treated as success (no-op). This is the manifest state-write path shared by promote and hotfix finalize: an API-created commit on real GitHub goes through a different path, so this is the plain-git fallback used when committing locally.

func CurrentBranch added in v0.2.0

func CurrentBranch() (string, error)

CurrentBranch returns the name of the currently checked-out branch. It returns an error if the HEAD is detached or the command fails.

func DeleteRemoteBranch added in v0.2.0

func DeleteRemoteBranch(remote, name string) error

DeleteRemoteBranch deletes the named branch on the given remote by running "git push <remote> --delete <name>". Deleting a branch that does not exist on the remote is treated as success so the operation is idempotent: re-running a rejoin cleanup after a partial failure does not error on an already-deleted branch.

func DeleteRemoteTag added in v0.2.0

func DeleteRemoteTag(remote, name string) error

DeleteRemoteTag deletes the named tag on the given remote by running "git push <remote> --delete refs/tags/<name>". Deleting a tag that does not exist on the remote is treated as success so the operation is idempotent.

func GetChangedFiles

func GetChangedFiles(baseSHA, headSHA string) ([]string, error)

GetChangedFiles returns the list of files changed between two commits

func GetInitialCommit

func GetInitialCommit() (string, error)

GetInitialCommit returns the SHA of the first commit in the repository

func GetLatestReleaseTag

func GetLatestReleaseTag(prefix string) (string, string, error)

GetLatestReleaseTag returns the most recent non-prerelease tag (no -rc suffix). This is used to find the base version for calculating next release versions.

func GetLatestTag

func GetLatestTag(prefix string) (string, string, error)

GetLatestTag returns the most recent tag matching the given prefix, sorted by semver. Returns empty string if no matching tags found.

func IsAncestor added in v0.2.0

func IsAncestor(ancestor, descendant string) (bool, error)

IsAncestor reports whether ancestor is an ancestor of descendant by running "git merge-base --is-ancestor". An exit code of 0 means true, an exit code of 1 means false, and any other exit code or execution failure is returned as an error.

Both commits must be present in the local object store. In a shallow clone the relevant history may be missing, so callers that rely on this must ensure full history is fetched (for example fetch-depth: 0).

func ListRemoteBranches added in v0.2.0

func ListRemoteBranches(remote string) ([]string, error)

ListRemoteBranches returns the branch names known for the given remote via the remote-tracking refs refs/remotes/<remote>/*. The remote prefix and the symbolic HEAD pointer are stripped, so "refs/remotes/origin/env/test" is returned as "env/test". The remote must have been fetched first; a shallow or partial fetch that omits branches will leave them out of the result.

func ListTags added in v0.2.0

func ListTags() ([]string, error)

ListTags returns every tag in the repository. It returns an empty slice when the repository has no tags.

func RemoteBranchSHA added in v0.2.0

func RemoteBranchSHA(remote, name string) (string, error)

RemoteBranchSHA returns the SHA of the remote-tracking ref refs/remotes/<remote>/<name> by running "git rev-parse". The returned SHA is whitespace-trimmed. An error is returned if the ref cannot be resolved.

This resolves a remote-tracking ref, so the remote must have been fetched first. A shallow or partial fetch that omits the branch will cause this to fail.

Types

type Commit

type Commit struct {
	Hash           string
	Subject        string
	Body           string
	Author         string
	AuthorEmail    string // Author email for deduplication
	GitHubUsername string // GitHub username (looked up via API)
}

Commit represents a git commit

func GetCommits

func GetCommits(baseSHA, headSHA string, excludePaths []string) ([]Commit, error)

GetCommits returns commits between two SHAs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL