git

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkout

func Checkout(ctx context.Context, repoPath, branch string, create bool) error

Checkout switches to the given branch. If create is true, creates the branch first.

func DefaultParallelism added in v0.0.4

func DefaultParallelism() int

DefaultParallelism keeps network fan-out bounded even on high-core machines.

func Log

func Log(ctx context.Context, repoPath string, max int) (string, error)

Log runs git log and returns oneline output.

func ScanGitRepos

func ScanGitRepos(ctx context.Context, rootDir string) ([]string, error)

Types

type BatchOptions added in v0.0.4

type BatchOptions struct {
	Parallel   int
	Timeout    time.Duration
	OnProgress func(completed, total int, result *OperationResult)
}

BatchOptions controls bounded parallel network operations across repositories.

type BranchInfo

type BranchInfo struct {
	Name    string // branch name, e.g. "main", "feature/foo"
	Current bool   // true if HEAD points to this branch
	Remote  string // upstream short ref, e.g. "origin/main", empty if no upstream
	Ahead   int    // commits ahead of upstream
	Behind  int    // commits behind upstream
}

BranchInfo holds metadata about a single local branch.

func GetBranches

func GetBranches(ctx context.Context, repoPath string) ([]BranchInfo, error)

GetBranches returns all local branches for a repo with upstream tracking info. The current branch is always first.

type CloneResult

type CloneResult struct {
	Name   string
	Path   string
	Output string
	Error  error
}

CloneResult holds the outcome of a single clone operation.

func Clone

func Clone(ctx context.Context, name string, spec CloneSpec) *CloneResult

Clone clones a single repo. If the target directory already exists, it skips.

func CloneAll

func CloneAll(ctx context.Context, rootDir string, specs map[string]CloneSpec, parallel int) []*CloneResult

type CloneSpec

type CloneSpec struct {
	Path   string
	Remote string
	Branch string
	Depth  int // 0 = full clone, >0 = shallow clone
}

CloneSpec describes a repo to clone.

type DiffFile

type DiffFile struct {
	Status string // "M", "A", "D", "R", "?"
	Path   string // relative file path
}

DiffFile represents a single changed file in the working tree.

func GetDiffFiles

func GetDiffFiles(ctx context.Context, repoPath string) ([]DiffFile, error)

GetDiffFiles returns all changed files (staged, unstaged, and untracked).

type FileDiff

type FileDiff struct {
	Path    string
	Content string
	Error   error
}

FileDiff holds the unified diff content for a single file.

func GetFileDiff

func GetFileDiff(ctx context.Context, repoPath, filePath string, isUntracked bool) *FileDiff

GetFileDiff returns the unified diff for a single file. For untracked files, compares against /dev/null.

type OperationResult

type OperationResult struct {
	Name   string
	Path   string
	Output string
	Error  error
}

OperationResult holds the outcome of a single pull or fetch operation.

func Fetch

func Fetch(ctx context.Context, name, repoPath string) *OperationResult

func FetchAll

func FetchAll(ctx context.Context, rootDir string, repos map[string]string, parallel int) []*OperationResult

func FetchAllWithOptions added in v0.0.4

func FetchAllWithOptions(ctx context.Context, rootDir string, repos map[string]string, opts BatchOptions) []*OperationResult

func Pull

func Pull(ctx context.Context, name, repoPath string) *OperationResult

func PullAll

func PullAll(ctx context.Context, rootDir string, repos map[string]string, parallel int) []*OperationResult

func PullAllWithOptions added in v0.0.4

func PullAllWithOptions(ctx context.Context, rootDir string, repos map[string]string, opts BatchOptions) []*OperationResult

type RemoteBranchInfo

type RemoteBranchInfo struct {
	Name string // e.g. "origin/main"
}

RemoteBranchInfo holds metadata about a remote-tracking branch.

func GetRemoteBranches

func GetRemoteBranches(ctx context.Context, repoPath string) ([]RemoteBranchInfo, error)

GetRemoteBranches returns all remote-tracking branches for a repo.

type RepoInfo

type RepoInfo struct {
	Remote string
	Branch string
}

RepoInfo holds metadata detected from an existing Git repository on disk.

func GetRepoInfo

func GetRepoInfo(ctx context.Context, repoPath string) RepoInfo

GetRepoInfo detects the remote URL (origin) and current branch of a repo.

type RepoStatus

type RepoStatus struct {
	Name     string
	Path     string
	Branch   string
	Remote   string
	Ahead    int
	Behind   int
	Worktree WorktreeStatus
	Error    error
}

func GetStatus

func GetStatus(ctx context.Context, name, repoPath string) *RepoStatus

func GetStatuses

func GetStatuses(ctx context.Context, rootDir string, repos map[string]string, parallel int) []*RepoStatus

func (*RepoStatus) IsClean

func (s *RepoStatus) IsClean() bool

func (*RepoStatus) StatusString

func (s *RepoStatus) StatusString() string

type WorktreeStatus

type WorktreeStatus int
const (
	StatusClean WorktreeStatus = iota
	StatusDirty
	StatusStaged
	StatusUntracked
	StatusConflicted
	StatusMissing
)

Jump to

Keyboard shortcuts

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