git

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 18 Imported by: 0

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 IsSupportedProtocol added in v0.1.0

func IsSupportedProtocol(u *url.URL) bool

func IsURL

func IsURL(u string) bool

func ParseURL

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

ParseURL normalizes git remote urls

Types

type BranchConfig

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

type Command

type Command struct {
	*exec.Cmd
}

func (*Command) Output

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

func (*Command) Run

func (gc *Command) Run() error

type CommandModifier

type CommandModifier func(*Command)

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

func WithRepoDir

func WithRepoDir(repoDir string) CommandModifier

func WithStderr

func WithStderr(stderr io.Writer) CommandModifier

func WithStdin

func WithStdin(stdin io.Reader) CommandModifier

func WithStdout

func WithStdout(stdout io.Writer) CommandModifier

type Commit

type Commit struct {
	Sha   string
	Title string
	Body  string
}

type GitCommand added in v0.1.0

type GitCommand interface {
	AddRemote(ctx context.Context, name, urlStr string, trackingBranches []string) (*Remote, error)
	AuthenticatedCommand(ctx context.Context, args ...string) (*Command, error)
	CheckoutBranch(ctx context.Context, branch string) error
	CheckoutNewBranch(ctx context.Context, remoteName, branch string) error
	Clone(ctx context.Context, cloneURL string, args []string, mods ...CommandModifier) (string, error)
	Command(ctx context.Context, args ...string) (*Command, error)
	CommitBody(ctx context.Context, sha string) (string, error)
	Commits(ctx context.Context, baseRef, headRef string) ([]*Commit, error)
	CurrentBranch(ctx context.Context) (string, error)
	DeleteLocalBranch(ctx context.Context, branch string) error
	DeleteLocalTag(ctx context.Context, tag string) error
	Fetch(ctx context.Context, remote string, refspec string, mods ...CommandModifier) error
	GetAuthConfig(ctx context.Context) (authConfig []string, err error)
	GetAzDoPath() string
	GetConfig(ctx context.Context, name string) (string, error)
	GetGitPath() string
	GetRepoDir() string
	GitDir(ctx context.Context) (string, error)
	HasLocalBranch(ctx context.Context, branch string) bool
	HasRemoteBranch(ctx context.Context, remote string, branch string) bool
	IsLocalGitRepo(ctx context.Context) (bool, error)
	LastCommit(ctx context.Context) (*Commit, error)
	ParentBranch(ctx context.Context, branch string) (string, error)
	PathFromRoot(ctx context.Context) string
	Pull(ctx context.Context, remote, branch string, mods ...CommandModifier) error
	Push(ctx context.Context, remote string, ref string, mods ...CommandModifier) error
	ReadBranchConfig(ctx context.Context, branch string) BranchConfig
	Remotes(ctx context.Context) (RemoteSet, error)
	// SetAzDoPath(string) error
	SetConfig(ctx context.Context, configItems ...string) (err error)
	// SetGitPath(string) error
	SetRemoteBranches(ctx context.Context, remote string, refspec string) error
	SetRemoteResolution(ctx context.Context, name, resolution string) error
	SetRepoDir(string) error
	ShowRefs(ctx context.Context, refs []string) ([]Ref, error)
	ToplevelDir(ctx context.Context) (string, error)
	TrackingBranchNames(ctx context.Context, prefix string) []string
	UncommittedChangeCount(ctx context.Context) (int, error)
	UnsetRemoteResolution(ctx context.Context, name string) error
	UpdateRemoteURL(ctx context.Context, name, url string) error
}

func NewGitCommand added in v0.1.0

func NewGitCommand(io *iostreams.IOStreams) (c GitCommand, err error)

type GitError

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

func (*GitError) Error

func (ge *GitError) Error() string

func (*GitError) Unwrap

func (ge *GitError) Unwrap() error

type NotInstalledError added in v0.0.2

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

func (*NotInstalledError) Error added in v0.0.2

func (e *NotInstalledError) Error() string

func (*NotInstalledError) Unwrap added in v0.0.2

func (e *NotInstalledError) 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, error)

func (*Remote) MarshalLogObject added in v0.6.0

func (r *Remote) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (*Remote) String

func (r *Remote) String() string

type RemoteSet

type RemoteSet []*Remote

RemoteSet is a slice of git remotes.

func (RemoteSet) Len

func (r RemoteSet) Len() int

func (RemoteSet) Less

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

func (RemoteSet) MarshalLogArray added in v0.6.0

func (r RemoteSet) MarshalLogArray(enc zapcore.ArrayEncoder) error

func (RemoteSet) Swap

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