Documentation
¶
Overview ¶
Package git provides helpers for interacting with local git repositories and configurations.
Index ¶
- func CurrentBranch(ctx context.Context, dir string) (string, error)
- func GetOrFetchBaseBranch(ctx context.Context, f forges.Forge, dir, owner, repo, branch string, ...) (string, error)
- func GetPRNumber(ctx context.Context, dir, branch string) (int, error)
- func PushBranch(ctx context.Context, dir, remote, branch string) error
- func SetBaseBranch(ctx context.Context, dir, branch, base string) error
- func SetPRNumber(ctx context.Context, dir, branch string, number int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentBranch ¶ added in v0.7.0
CurrentBranch returns the current local branch name.
func GetOrFetchBaseBranch ¶
func GetOrFetchBaseBranch(ctx context.Context, f forges.Forge, dir, owner, repo, branch string, forceRefresh bool) (string, error)
GetOrFetchBaseBranch returns the base branch of the given branch. It first checks the local git configuration for a cached value. If not found, it queries the forge API for an open pull request for the branch, caches the base branch name in the local git configuration, and returns it. If branch is empty, it uses the current branch.
func GetPRNumber ¶ added in v0.7.0
GetPRNumber returns the cached pull request number for a branch.
func PushBranch ¶ added in v0.10.0
PushBranch pushes a local branch to the same branch name on a remote. It configures upstream tracking only when the remote fetches from and pushes to the same repository, so a fork push URL cannot replace existing tracking for the upstream repository.
func SetBaseBranch ¶
SetBaseBranch caches the base branch for a branch in the local git configuration.
Types ¶
This section is empty.