git

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git reads the local branch state the pr command needs. It shells out to git rather than linking a git library: the CLI already assumes a checkout with a remote (that's how the repo is detected), and the two facts needed here are one command each.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	// Branch is the current branch name, empty on a detached HEAD.
	Branch string
	// Upstream is the branch name on the remote, empty when the branch
	// tracks nothing there. It is not always the local name: see Head.
	Upstream string
	// Pushed reports whether the branch has a remote-tracking counterpart.
	// GitHub can only open a pull request for a ref it can already see, so
	// this is a precondition, not a nicety.
	Pushed bool
}

State is the local branch state a pull request is opened from.

func Current

func Current() (State, error)

Current reads the state of the checkout in the working directory.

func (State) Head added in v0.8.0

func (s State) Head() string

Head is the branch a pull request is opened from — the upstream name when there is one, the local name otherwise. The two differ whenever a checkout is made under a generated local name: an agent harness working in a git worktree ends up on worktree-feat+x tracking origin/feat/x, and GitHub has never heard of the local name, so a PR opened from it is rejected outright.

Jump to

Keyboard shortcuts

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