git

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProjectRoot string

ProjectRoot is the working directory for all git commands. Deprecated: will be removed once all callers migrate to GitClient.

Functions

func ActiveReleaseBranches

func ActiveReleaseBranches() []string

func AllLocalBranches

func AllLocalBranches() []string

func BranchCommitSubjects

func BranchCommitSubjects(parentBranch, branchName string) []string

BranchCommitSubjects returns the commit message subjects (first line) for commits reachable from branchName but not from parentBranch, excluding merge commits. These are the work-commits that will land in the parent on finish.

func BranchExists

func BranchExists(name string) bool

func BranchMergeCommitSubjects

func BranchMergeCommitSubjects(parentBranch, branchName string) []string

BranchMergeCommitSubjects returns merge-commit subjects for commits reachable from branchName but not from parentBranch. A non-zero result means the branch has sync merges that could be rebased away for a cleaner graph before finishing.

func BranchTypeOf

func BranchTypeOf(name string) string

BranchTypeOf delegates to branch.TypeOf for backward compatibility.

func CurrentBranch

func CurrentBranch() string

func Exec

func Exec(args ...string) error

Exec runs git with explicit arguments (no shell interpretation). This is the safe replacement for Run() that prevents shell injection.

func ExecLines

func ExecLines(args ...string) []string

ExecLines runs git with explicit arguments and returns stdout split by newline.

func ExecQuiet

func ExecQuiet(args ...string) string

ExecQuiet runs git with explicit arguments and returns only stdout.

func ExecResult

func ExecResult(args ...string) (int, string, string)

ExecResult runs git with explicit arguments and captures output.

func ExecSilent

func ExecSilent(args ...string) error

ExecSilent runs git without logging the command or printing any output. Use for internal plumbing (init, branch creation, commits) where verbose output would pollute the user-facing progress display.

func FlowVersion

func FlowVersion(version string) string

func HasStagedChanges

func HasStagedChanges() bool

func HasUncommittedChanges

func HasUncommittedChanges() bool

func IsGitFlowInitialized

func IsGitFlowInitialized() bool

func IsGitRepo

func IsGitRepo() bool

func LatestTag

func LatestTag() string

func RemoteExists

func RemoteExists(name string) bool

func Remotes

func Remotes() []string

func RemovePrefix

func RemovePrefix(s, prefix string) string

func Run

func Run(cmdStr string) error

func RunLines

func RunLines(cmdStr string) []string

func RunQuiet

func RunQuiet(cmdStr string) string

func RunResult

func RunResult(cmdStr string) (int, string, string)

func SetDefaultClient

func SetDefaultClient(c GitClient)

SetDefaultClient replaces the package default client (useful for tests).

func SplitCommand

func SplitCommand(s string) []string

SplitCommand is an exported wrapper around splitCommand. Use this when callers need to convert a single command string into args suitable for exec.Command without invoking a shell. This helps migrate callers away from legacy Run()/RunResult() wrappers.

func StashPop

func StashPop() error

func StashSave

func StashSave(msg string) error

func TagExists

func TagExists(tag string) bool

Types

type GitClient

type GitClient interface {
	Exec(args ...string) error
	ExecResult(args ...string) (int, string, string)
	ExecQuiet(args ...string) string
	ExecLines(args ...string) []string
}

GitClient abstracts git command execution for easier testing and migration away from package-level globals.

func DefaultClient

func DefaultClient() GitClient

DefaultClient returns the current default GitClient. When no override is set, a dynamic client is returned so the effective working directory follows mutations to `git.ProjectRoot` (important for tests).

type LocalGitClient

type LocalGitClient struct {
	Root string
}

LocalGitClient runs git commands in a specific working directory.

func NewLocalGitClient

func NewLocalGitClient(root string) *LocalGitClient

NewLocalGitClient creates a LocalGitClient bound to the provided root.

func (*LocalGitClient) Exec

func (c *LocalGitClient) Exec(args ...string) error

func (*LocalGitClient) ExecLines

func (c *LocalGitClient) ExecLines(args ...string) []string

func (*LocalGitClient) ExecQuiet

func (c *LocalGitClient) ExecQuiet(args ...string) string

func (*LocalGitClient) ExecResult

func (c *LocalGitClient) ExecResult(args ...string) (int, string, string)

type WorkTreeStatus

type WorkTreeStatus struct {
	Staged    int
	Unstaged  int
	Untracked int
	Total     int
}

func WorkingTreeStatus

func WorkingTreeStatus() WorkTreeStatus

Jump to

Keyboard shortcuts

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