git

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanFastForward

func CanFastForward(path, branch string) bool

CanFastForward returns true if HEAD can be fast-forwarded to origin/branch.

func Clone

func Clone(url, path string) error

Clone clones a git repository. Authentication is handled by the credential helper configured via `gh auth login`.

func CommitsBehind

func CommitsBehind(path, branch string) (int, error)

CommitsBehind returns the number of commits HEAD is behind origin/branch.

func CurrentBranch

func CurrentBranch(path string) (string, error)

CurrentBranch returns the name of the currently checked-out branch.

func FastForward

func FastForward(path string) error

FastForward performs a fast-forward merge from the upstream tracking branch.

func Fetch

func Fetch(path string) error

Fetch runs git fetch origin in the given repository. Authentication is handled by the credential helper configured via `gh auth login`.

func IsClean

func IsClean(path string) bool

IsClean returns true if the working tree has no modifications, staged changes, or untracked files.

func IsRepo

func IsRepo(path string) bool

IsRepo returns true if path contains a .git directory.

Types

type SyncResult

type SyncResult struct {
	Status  SyncStatus
	Commits int   // Number of commits pulled (only for StatusPulled)
	Error   error // Underlying error (only for StatusError)
}

SyncResult holds the outcome of syncing a repository.

func SyncRepo

func SyncRepo(path string) SyncResult

SyncRepo fetches from origin and conditionally fast-forwards. It never modifies a dirty worktree and never does non-fast-forward merges. Authentication is handled by the credential helper configured via `gh auth login`.

type SyncStatus

type SyncStatus int

SyncStatus represents the outcome of a sync operation.

const (
	StatusPulled   SyncStatus = iota // Fast-forwarded successfully
	StatusUpToDate                   // Already at latest commit
	StatusFetched                    // Fetched only (dirty worktree or diverged)
	StatusError                      // Operation failed
)

Jump to

Keyboard shortcuts

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