git

package
v2.49.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotOnAnyBranch = errors.New("git: not on any branch")

ErrNotOnAnyBranch indicates that the user is in detached HEAD state.

Functions

func IsURL

func IsURL(u string) bool

func ParseURL

func ParseURL(rawURL string) (*url.URL, error)

ParseURL normalizes git remote urls

Types

type BranchConfig

type BranchConfig struct {
	RemoteName string
	RemoteURL  *url.URL
	MergeRef   string
}

type Client added in v2.18.0

type Client struct {
	GhPath  string
	RepoDir string
	GitPath string
	Stderr  io.Writer
	Stdin   io.Reader
	Stdout  io.Writer
	// contains filtered or unexported fields
}

func (*Client) AddRemote added in v2.18.0

func (c *Client) AddRemote(ctx context.Context, name, urlStr string, trackingBranches []string) (*Remote, error)

func (*Client) AuthenticatedCommand added in v2.18.0

func (c *Client) AuthenticatedCommand(ctx context.Context, args ...string) (*Command, error)

AuthenticatedCommand is a wrapper around Command that included configuration to use gh as the credential helper for git.

func (*Client) CheckoutBranch added in v2.18.0

func (c *Client) CheckoutBranch(ctx context.Context, branch string) error

func (*Client) CheckoutNewBranch added in v2.18.0

func (c *Client) CheckoutNewBranch(ctx context.Context, remoteName, branch string) error

func (*Client) Clone added in v2.18.0

func (c *Client) Clone(ctx context.Context, cloneURL string, args []string, mods ...CommandModifier) (string, error)

func (*Client) Command added in v2.18.0

func (c *Client) Command(ctx context.Context, args ...string) (*Command, error)

func (*Client) CommitBody added in v2.18.0

func (c *Client) CommitBody(ctx context.Context, sha string) (string, error)

func (*Client) Commits added in v2.18.0

func (c *Client) Commits(ctx context.Context, baseRef, headRef string) ([]*Commit, error)

func (*Client) Config added in v2.18.0

func (c *Client) Config(ctx context.Context, name string) (string, error)

func (*Client) Copy added in v2.31.0

func (c *Client) Copy() *Client

func (*Client) CurrentBranch added in v2.18.0

func (c *Client) CurrentBranch(ctx context.Context) (string, error)

CurrentBranch reads the checked-out branch for the git repository.

func (*Client) DeleteLocalBranch added in v2.18.0

func (c *Client) DeleteLocalBranch(ctx context.Context, branch string) error

func (*Client) DeleteLocalTag added in v2.35.0

func (c *Client) DeleteLocalTag(ctx context.Context, tag string) error

func (*Client) Fetch added in v2.19.0

func (c *Client) Fetch(ctx context.Context, remote string, refspec string, mods ...CommandModifier) error

func (*Client) GitDir added in v2.18.0

func (c *Client) GitDir(ctx context.Context) (string, error)

func (*Client) HasLocalBranch added in v2.18.0

func (c *Client) HasLocalBranch(ctx context.Context, branch string) bool

func (*Client) IsLocalGitRepo added in v2.22.0

func (c *Client) IsLocalGitRepo(ctx context.Context) (bool, error)

func (*Client) LastCommit added in v2.18.0

func (c *Client) LastCommit(ctx context.Context) (*Commit, error)

func (*Client) PathFromRoot added in v2.18.0

func (c *Client) PathFromRoot(ctx context.Context) string

Show current directory relative to the top-level directory of repository.

func (*Client) Pull added in v2.18.0

func (c *Client) Pull(ctx context.Context, remote, branch string, mods ...CommandModifier) error

func (*Client) Push added in v2.18.0

func (c *Client) Push(ctx context.Context, remote string, ref string, mods ...CommandModifier) error

func (*Client) ReadBranchConfig added in v2.18.0

func (c *Client) ReadBranchConfig(ctx context.Context, branch string) (cfg BranchConfig)

ReadBranchConfig parses the `branch.BRANCH.(remote|merge)` part of git config.

func (*Client) Remotes added in v2.18.0

func (c *Client) Remotes(ctx context.Context) (RemoteSet, error)

func (*Client) SetRemoteBranches added in v2.31.0

func (c *Client) SetRemoteBranches(ctx context.Context, remote string, refspec string) error

func (*Client) SetRemoteResolution added in v2.18.0

func (c *Client) SetRemoteResolution(ctx context.Context, name, resolution string) error

func (*Client) ShowRefs added in v2.18.0

func (c *Client) ShowRefs(ctx context.Context, refs []string) ([]Ref, error)

ShowRefs resolves fully-qualified refs to commit hashes.

func (*Client) ToplevelDir added in v2.18.0

func (c *Client) ToplevelDir(ctx context.Context) (string, error)

ToplevelDir returns the top-level directory path of the current repository.

func (*Client) TrackingBranchNames added in v2.26.0

func (c *Client) TrackingBranchNames(ctx context.Context, prefix string) []string

func (*Client) UncommittedChangeCount added in v2.18.0

func (c *Client) UncommittedChangeCount(ctx context.Context) (int, error)

func (*Client) UnsetRemoteResolution added in v2.21.0

func (c *Client) UnsetRemoteResolution(ctx context.Context, name string) error

func (*Client) UpdateRemoteURL added in v2.18.0

func (c *Client) UpdateRemoteURL(ctx context.Context, name, url string) error

type Command added in v2.20.1

type Command struct {
	*exec.Cmd
}

func (*Command) Output added in v2.20.1

func (gc *Command) Output() ([]byte, error)

func (*Command) Run added in v2.20.1

func (gc *Command) Run() error

type CommandModifier added in v2.19.0

type CommandModifier func(*Command)

Allow individual commands to be modified from the default client options.

func WithRepoDir added in v2.19.0

func WithRepoDir(repoDir string) CommandModifier

func WithStderr added in v2.19.0

func WithStderr(stderr io.Writer) CommandModifier

func WithStdin added in v2.19.0

func WithStdin(stdin io.Reader) CommandModifier

func WithStdout added in v2.19.0

func WithStdout(stdout io.Writer) CommandModifier

type Commit

type Commit struct {
	Sha   string
	Title string
	Body  string
}

type GitError added in v2.18.0

type GitError struct {
	ExitCode int
	Stderr   string
	// contains filtered or unexported fields
}

func (*GitError) Error added in v2.18.0

func (ge *GitError) Error() string

func (*GitError) Unwrap added in v2.18.0

func (ge *GitError) Unwrap() error

type NotInstalled

type NotInstalled struct {
	// contains filtered or unexported fields
}

func (*NotInstalled) Error

func (e *NotInstalled) Error() string

func (*NotInstalled) Unwrap added in v2.18.0

func (e *NotInstalled) Unwrap() error

type Ref

type Ref struct {
	Hash string
	Name string
}

Ref represents a git commit reference.

type Remote

type Remote struct {
	Name     string
	Resolved string
	FetchURL *url.URL
	PushURL  *url.URL
}

Remote is a parsed git remote.

func NewRemote

func NewRemote(name string, u string) *Remote

func (*Remote) String

func (r *Remote) String() string

type RemoteSet

type RemoteSet []*Remote

RemoteSet is a slice of git remotes.

func (RemoteSet) Len added in v2.18.0

func (r RemoteSet) Len() int

func (RemoteSet) Less added in v2.18.0

func (r RemoteSet) Less(i, j int) bool

func (RemoteSet) Swap added in v2.18.0

func (r RemoteSet) Swap(i, j int)

type TrackingRef

type TrackingRef struct {
	RemoteName string
	BranchName string
}

TrackingRef represents a ref for a remote tracking branch.

func (TrackingRef) String

func (r TrackingRef) String() string

Jump to

Keyboard shortcuts

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