Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package gitcmd provides functions for interacting with the git command-line tool.
Index ¶
- Variables
 - func DeleteBranches(ctx context.Context, branches []BranchToDelete, dryRun bool) []types.DeleteResult
 - func FetchAndPrune(ctx context.Context, remoteName string) error
 - func GetAllLocalBranchInfo(ctx context.Context) ([]types.BranchInfo, error)
 - func GetCurrentBranchName(ctx context.Context) (string, error)
 - func GetMainBranchHash(ctx context.Context, branchName string) (string, error)
 - func GetMergedBranches(ctx context.Context, targetHash string) (map[string]bool, error)
 - func IsInGitRepo(ctx context.Context) (bool, error)
 - func RunGitCommand(ctx context.Context, args ...string) (string, error)
 - type BranchToDelete
 - type GitRunner
 
Constants ¶
This section is empty.
Variables ¶
var AreChangesIncluded areChangesIncludedFunc = areChangesIncludedImpl
    AreChangesIncluded is a variable holding the implementation, allowing mocking. It checks if all changes in headBranch are included in upstreamBranch using 'git cherry -v'.
Functions ¶
func DeleteBranches ¶
func DeleteBranches(ctx context.Context, branches []BranchToDelete, dryRun bool) []types.DeleteResult
DeleteBranches attempts to delete the specified local and remote branches. It takes a slice of BranchToDelete structs and returns a slice of DeleteResult detailing the outcome of each attempt.
func FetchAndPrune ¶
FetchAndPrune runs 'git fetch <remote> --prune' to update local refs and remove any stale remote-tracking branches. It returns an error if the command fails, but the plan suggests treating this as a warning rather than a fatal error in the main application flow.
func GetAllLocalBranchInfo ¶
func GetAllLocalBranchInfo(ctx context.Context) ([]types.BranchInfo, error)
GetAllLocalBranchInfo retrieves information about all local branches.
func GetCurrentBranchName ¶
GetCurrentBranchName retrieves the name of the currently checked-out branch. It returns an empty string if HEAD is detached or if an error occurs.
func GetMainBranchHash ¶
GetMainBranchHash retrieves the commit hash for the specified branch name.
func GetMergedBranches ¶
GetMergedBranches returns a map of branch names that are fully merged into the specified commit hash. The map value is always true.
func IsInGitRepo ¶
IsInGitRepo checks if the current directory is within a Git working tree.
Types ¶
type BranchToDelete ¶
type BranchToDelete struct {
	Name     string
	IsRemote bool
	Remote   string // Only used if IsRemote is true
	IsMerged bool   // Used to determine -d vs -D for local delete
	Hash     string // Potentially useful for logging/confirmation
}
    BranchToDelete holds information needed to delete a specific branch.
type GitRunner ¶
GitRunner defines the function signature for executing git commands. This allows mocking the actual git execution during tests.
var Runner GitRunner = runGitCommandReal
    Runner is the package-level variable holding the function used to run git commands. It defaults to the real implementation but can be swapped out in tests.