git

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package git provides a wrapper for git operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CIStatus

type CIStatus struct {
	State       string        // "success", "pending", "failure", "error"
	TotalCount  int           // Total number of checks
	Statuses    []CheckStatus // Individual check statuses
	CheckSuites []CheckSuite  // GitHub Actions check suites
}

CIStatus represents the combined status of CI checks.

type CheckStatus

type CheckStatus struct {
	Context     string // Check name/context
	State       string // "success", "pending", "failure", "error"
	Description string // Status description
	TargetURL   string // URL to check details
}

CheckStatus represents a single status check.

type CheckSuite

type CheckSuite struct {
	App        string // App name (e.g., "GitHub Actions")
	Status     string // "queued", "in_progress", "completed"
	Conclusion string // "success", "failure", "neutral", etc. (only if completed)
}

CheckSuite represents a GitHub Actions check suite.

type Git

type Git struct {
	Dir    string // Repository directory
	Remote string // Remote name (default: origin)
}

Git provides git operations for a repository.

func New

func New(dir string) *Git

New creates a new Git instance for the given directory.

func (*Git) AllTags

func (g *Git) AllTags() ([]string, error)

AllTags returns all tags in the repository, sorted by version.

func (*Git) Commit

func (g *Git) Commit(message string, sign bool) error

Commit creates a commit with currently staged changes.

func (*Git) CommitAll

func (g *Git) CommitAll(message string, sign bool) error

CommitAll stages all changes and creates a commit.

func (*Git) CreateTag

func (g *Git) CreateTag(tag string, message string, sign bool) error

CreateTag creates a new tag at HEAD.

func (*Git) CurrentBranch

func (g *Git) CurrentBranch() (string, error)

CurrentBranch returns the current branch name.

func (*Git) CurrentCommit

func (g *Git) CurrentCommit() (string, error)

CurrentCommit returns the current commit SHA.

func (*Git) DeleteTag

func (g *Git) DeleteTag(tag string) error

DeleteTag deletes a local tag.

func (*Git) Fetch

func (g *Git) Fetch() error

Fetch fetches from the remote.

func (*Git) FetchTags

func (g *Git) FetchTags() error

FetchTags fetches tags from the remote.

func (*Git) GetCIStatus

func (g *Git) GetCIStatus(ref string) (*CIStatus, error)

GetCIStatus retrieves the CI status for a commit.

func (*Git) GetPRForBranch

func (g *Git) GetPRForBranch() (int, error)

GetPRForBranch gets the PR number for the current branch.

func (*Git) GetPRStatus

func (g *Git) GetPRStatus(prNumber int) (*CIStatus, error)

GetPRStatus gets the CI status for a PR.

func (*Git) IsAncestor

func (g *Git) IsAncestor(ancestor, descendant string) (bool, error)

IsAncestor checks if ancestor is an ancestor of descendant.

func (*Git) IsCIPassing

func (g *Git) IsCIPassing(ref string) (bool, error)

IsCIPassing checks if CI is currently passing (without waiting).

func (*Git) IsDirty

func (g *Git) IsDirty() (bool, error)

IsDirty returns true if there are uncommitted changes.

func (*Git) LatestTag

func (g *Git) LatestTag() (string, error)

LatestTag returns the most recent tag reachable from HEAD.

func (*Git) Log

func (g *Git) Log(from, to string, format string) (string, error)

Log returns commit messages between two refs.

func (*Git) Push

func (g *Git) Push(refs ...string) error

Push pushes refs to the remote.

func (*Git) PushTag

func (g *Git) PushTag(tag string) error

PushTag pushes a specific tag to the remote.

func (*Git) PushWithUpstream

func (g *Git) PushWithUpstream() error

PushWithUpstream pushes the current branch and sets upstream.

func (*Git) RemoteURL

func (g *Git) RemoteURL() (string, error)

RemoteURL returns the URL of the remote.

func (*Git) ShortCommit

func (g *Git) ShortCommit() (string, error)

ShortCommit returns the short form of the current commit SHA.

func (*Git) Status

func (g *Git) Status() (*Status, error)

Status returns the current git status.

func (*Git) WaitForCI

func (g *Git) WaitForCI(timeout time.Duration) error

WaitForCI waits for CI to complete with a timeout.

type Status

type Status struct {
	Branch       string   // Current branch name
	Ahead        int      // Commits ahead of remote
	Behind       int      // Commits behind remote
	Staged       []string // Staged files
	Modified     []string // Modified but unstaged files
	Untracked    []string // Untracked files
	HasRemote    bool     // Whether branch has a remote tracking branch
	RemoteBranch string   // Remote tracking branch
	IsClean      bool     // No uncommitted changes
}

Status represents the current git status.

Jump to

Keyboard shortcuts

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