git

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const RemoteGitUrlRegex = "((git|ssh|http(s)?)|(git@[\\w\\.]+))(:(//)?)([\\w\\.@\\:/\\-~]+)(\\.git)(/)?"

Variables

View Source
var ErrInvalidGitUrl = errors.New("invalid git remote repository url")
View Source
var ErrInvalidReference = errors.New("invalid remote reference")

Functions

This section is empty.

Types

type BranchName

type BranchName string

type CloneOps

type CloneOps struct {
	Remote RemoteGitUrl
	Path   string
	Refs   BranchName
}

type CommandBuilder

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

func NewCommandBuilder

func NewCommandBuilder() *CommandBuilder

func (*CommandBuilder) Arg

func (cb *CommandBuilder) Arg(args ...string) *CommandBuilder

func (*CommandBuilder) ArgIf

func (cb *CommandBuilder) ArgIf(cond bool, args ...string) *CommandBuilder

func (*CommandBuilder) Run

func (cb *CommandBuilder) Run() error

func (*CommandBuilder) RunWithExitCode

func (cb *CommandBuilder) RunWithExitCode() int

func (*CommandBuilder) RunWithOutput

func (cb *CommandBuilder) RunWithOutput() (string, error)

func (*CommandBuilder) SetRepo

func (cb *CommandBuilder) SetRepo(r Repo) *CommandBuilder

func (*CommandBuilder) String

func (cb *CommandBuilder) String() string

type Git

type Git interface {
	Clone(ops CloneOps) error
	ListRemotes(repo Repo) ([]Remote, error)
	Fetch(repo Repo) error
	Status(repo Repo) (StatusRes, error)
	CurrentBranch(repo Repo) (BranchName, error)
	HasChanges(repo Repo) (bool, error)
	DiffersFromRemote(repo Repo) (bool, error)
	Switch(repo Repo, branch BranchName, force bool) error
	Pull(repo Repo, rebase bool) error
	PullBranch(repo Repo, branch BranchName, rebase bool) error
	ListBranches(repo Repo) ([]BranchName, error)
	CreateLightweightTag(repo Repo, tag string, branch BranchName) error
	PushTag(repo Repo, tag Tag, remote Remote) error
}

type GitCLI

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

func NewGitCLI

func NewGitCLI() (GitCLI, error)

func (GitCLI) Clone

func (gc GitCLI) Clone(ops CloneOps) error

func (GitCLI) CreateLightweightTag

func (gc GitCLI) CreateLightweightTag(repo Repo, tag string, branch BranchName) error

func (GitCLI) CurrentBranch

func (gc GitCLI) CurrentBranch(repo Repo) (BranchName, error)

func (GitCLI) DiffersFromRemote

func (gc GitCLI) DiffersFromRemote(repo Repo) (bool, error)

func (GitCLI) Fetch

func (gc GitCLI) Fetch(repo Repo) error

func (GitCLI) HasChanges

func (gc GitCLI) HasChanges(repo Repo) (bool, error)

func (GitCLI) ListBranches

func (gc GitCLI) ListBranches(repo Repo) ([]BranchName, error)

func (GitCLI) ListRemotes

func (gc GitCLI) ListRemotes(repo Repo) ([]Remote, error)

func (GitCLI) Pull

func (gc GitCLI) Pull(repo Repo, rebase bool) error

func (GitCLI) PullBranch

func (gc GitCLI) PullBranch(repo Repo, branch BranchName, rebase bool) error

func (GitCLI) PushTag

func (gc GitCLI) PushTag(repo Repo, tag Tag, remote Remote) error

func (GitCLI) Status

func (gc GitCLI) Status(repo Repo) (StatusRes, error)

func (GitCLI) Switch

func (gc GitCLI) Switch(repo Repo, br BranchName, force bool) error

type Remote

type Remote string

type RemoteGitUrl

type RemoteGitUrl string

func NewRemoteGitUrl

func NewRemoteGitUrl(raw string) (RemoteGitUrl, error)

type Repo

type Repo struct {
	Remote RemoteGitUrl `yaml:"remote" json:"remote,omitempty"`
	Path   string       `yaml:"rel_path" json:"rel_path,omitempty"`
	Refs   BranchName   `yaml:"main_stream" json:"main_stream,omitempty"`
}

type StatusRes

type StatusRes struct {
	Change bool
	Branch BranchName
}

type Tag

type Tag string

Jump to

Keyboard shortcuts

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