git

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 19 Imported by: 0

README

Git Operations Module

This package provides comprehensive Git repository operations for the Hitch workflow management system. The module has been refactored from a monolithic 551-line file into focused, single-responsibility modules with proper error handling and security validation.

Overview

The git operations module consists of:

  • Repository Management - Core repository operations and state management
  • Branch Operations - Branch creation, deletion, and validation
  • Merge Operations - Advanced merge capabilities with conflict handling
  • Remote Operations - Push/pull operations with safety checks
  • Security - Input sanitization and command injection prevention
  • Error Handling - Structured error types for all git operations

Architecture

Module Structure
internal/git/
├── README.md              # This documentation
├── repo.go               # Core repository management and initialization
├── repo_branches.go      # Branch operations (create, delete, validate)
├── repo_merges.go        # Merge operations with conflict detection
├── repo_remotes.go       Remote operations (push, pull with safety)
├── repo_state.go         # Repository state and status queries
├── repo_info.go          # Repository information and metadata
├── repo_user.go          # User-related git operations
├── operations.go         # Low-level git command execution
├── sanitizer.go          # Input security and validation
├── validator.go          // Git-specific validation logic
├── conflict_handler.go   // Merge conflict resolution
├── command_helpers.go    // Command execution utilities
└── git_test.go           // Comprehensive test suite

Core Components

Repository Management

The Repo struct is the central interface for all git operations:

type Repo struct {
    *git.Repository        // go-git repository instance
    workdir             string // Working directory path
    mutex               sync.RWMutex // Thread safety
}
Key Functions
// Repository initialization
func OpenRepo(path string) (*Repo, error)
func (r *Repo) IsBare() bool
func (r *Repo) IsEmpty() bool
func (r *Repo) WorkingTree() string

// Repository state
func (r *Repo) HasUncommittedChanges() (bool, error)
func (r *Repo) HasStagedChanges() (bool, error)
func (r *Repo) GetCurrentBranch() (string, error)
func (r *Repo) IsCleanWorkingTree() (bool, error)
Branch Operations

Comprehensive branch management with security validation:

// Branch existence and validation
func (r *Repo) BranchExists(name string) bool
func (r *Repo) CreateBranch(name string, fromRef string) error
func (r *Repo) DeleteBranch(name string, force bool) error
func (r *Repo) DeleteRemoteBranch(remoteName, branchName string) error

// Branch listing and information
func (r *Repo) GetBranches() ([]string, error)
func (r *Repo) GetRemoteBranches() ([]string, error)
func (r *Repo) GetLocalBranches() ([]string, error)
Security Features

All branch operations include:

  • Input Sanitization - Prevents command injection attacks
  • Name Validation - Ensures git-safe branch names
  • Permission Checks - Validates branch operation permissions
  • Error Handling - Structured error types for better debugging
Merge Operations

Advanced merge capabilities with conflict detection and resolution:

// Merge operations
func (r *Repo) Merge(branch string, message string) error
func (r *Repo) MergeSquash(branch string, message string) error
func (r *Repo) MergeAbort() error
func (r *Repo) IsMergeInProgress() bool

// Merge validation
func (r *Repo) CanMerge(branch string) (bool, error)

// Conflict handling
func (r *Repo) GetConflictingFiles() ([]string, error)
func (r *Repo) HasConflicts() (bool, error)
Conflict Detection

The system automatically detects and reports merge conflicts:

type MergeConflictError struct {
    Branch       string   // Source branch
    ConflictFiles []string // Files with conflicts
    Message      string   // Detailed conflict information
}
Remote Operations

Safe push/pull operations with force-with-lease protection:

// Push and pull operations
func (r *Repo) Pull(remoteName, branchName string) error
func (r *Repo) Push(remoteName, branchName string, force bool) error

// Remote management
func (r *Repo) AddRemote(name, url string) error
func (r *Repo) RemoveRemote(name string) error
func (r *Repo) GetRemotes() ([]string, error)
func (r *Repo) GetRemoteURL(name string) (string, error)
Safety Features
  • Force-with-Lease - Safe force pushes that respect remote changes
  • Connection Validation - Validates remote URLs and connections
  • Operation Safety - Prevents destructive operations without confirmation
Security and Validation
Input Sanitization
type InputSanitizer struct{}

func (s *InputSanitizer) SanitizeBranchName(branch string) error
func (s *InputSanitizer) SanitizeCommitMessage(message string) error
func (s *InputSanitizer) SanitizeRemoteName(remote string) error
func (s *InputSanitizer) ValidateRef(ref string) error
Security Features
  • Command Injection Prevention - Blocks dangerous shell metacharacters
  • Path Traversal Protection - Prevents ../ attacks
  • Length Validation - Prevents DoS attacks with long inputs
  • Character Validation - Ensures only safe characters are used
  • Pattern Detection - Identifies suspicious command patterns

Usage Examples

Basic Repository Operations
// Open a repository
repo, err := git.OpenRepo("/path/to/repo")
if err != nil {
    return fmt.Errorf("failed to open repository: %w", err)
}
defer repo.Close()

// Check repository state
isClean, err := repo.IsCleanWorkingTree()
if err != nil {
    return fmt.Errorf("failed to check repository state: %w", err)
}

if !isClean {
    fmt.Println("Repository has uncommitted changes")
}
Branch Operations
// Create a new branch
err := repo.CreateBranch("feature/new-feature", "main")
if err != nil {
    // Returns structured GitBranchError
    return fmt.Errorf("failed to create branch: %w", err)
}

// Check if branch exists
if repo.BranchExists("feature/new-feature") {
    fmt.Println("Branch already exists")
}

// Delete a branch (with force option)
err = repo.DeleteBranch("feature/old-feature", true)
if err != nil {
    return fmt.Errorf("failed to delete branch: %w", err)
}
Merge Operations
// Test if merge is possible
canMerge, err := repo.CanMerge("feature/branch")
if err != nil {
    return fmt.Errorf("failed to test merge: %w", err)
}

if canMerge {
    // Perform the merge
    err = repo.Merge("feature/branch", "Merge feature branch")
    if err != nil {
        // Handle merge conflicts
        if mergeErr, ok := err.(*MergeConflictError); ok {
            fmt.Printf("Merge conflicts in: %v\n", mergeErr.ConflictFiles)
            return handleConflicts(mergeErr)
        }
        return fmt.Errorf("merge failed: %w", err)
    }
    fmt.Println("Merge completed successfully")
}
Remote Operations
// Safe push with force-with-lease
err := repo.Push("origin", "feature-branch", false) // No force
if err != nil {
    return fmt.Errorf("push failed: %w", err)
}

// Pull latest changes
err = repo.Pull("origin", "main")
if err != nil {
    // Returns structured GitPullError
    return fmt.Errorf("pull failed: %w", err)
}
Security Validation
// Create input sanitizer
sanitizer := git.NewInputSanitizer()

// Validate user input
branchName := getUserInput()
if err := sanitizer.SanitizeBranchName(branchName); err != nil {
    return fmt.Errorf("invalid branch name: %w", err)
}

// Safe to use the validated branch name
err = repo.CreateBranch(branchName, "main")

Error Handling

All operations return structured error types:

// Category-based error handling
func handleGitError(err error) error {
    if err == nil {
        return nil
    }

    switch errors.GetCategory(err) {
    case errors.CategoryGitOperation:
        // Handle git-specific errors
        if gitErr, ok := err.(*errors.GitOperationError); ok {
            fmt.Printf("Git %s operation failed: %s\n", gitErr.Operation, gitErr.Reason)
        }
    case errors.CategoryValidation:
        // Handle validation errors
        return fmt.Errorf("input validation failed: %w", err)
    default:
        return fmt.Errorf("unexpected error: %w", err)
    }
}

Integration

With Validation Framework
import "github.com/DoomedRamen/hitch/internal/validation"

// Use validation framework with git operations
adapter := validation.BranchValidationAdapter()

func createValidBranch(name string) error {
    // Validate using common validation framework
    if err := adapter.ValidateWithErrors(name, name); err != nil {
        return err
    }

    // Safe to create branch
    return repo.CreateBranch(name, "main")
}
With Error Handling System
import hitcherrors "github.com/DoomedRamen/hitch/internal/errors"

func performSafeMerge(branch string) error {
    // Check merge compatibility
    canMerge, err := repo.CanMerge(branch)
    if err != nil {
        return hitcherrors.NewGitOperationError("merge-test", branch, "failed to test merge", err)
    }

    if !canMerge {
        return hitcherrors.NewValidationError("cannot merge", "branch has conflicts")
    }

    // Perform merge
    err = repo.Merge(branch, "Automated merge")
    if err != nil {
        return hitcherrors.NewGitMergeError(branch, "merge failed", err.Error())
    }

    return nil
}

Performance Considerations

  • Repository Caching - Repository instances are cached for performance
  • Command Efficiency - Git commands are optimized and batched when possible
  • Concurrent Safety - Thread-safe operations with proper locking
  • Memory Management - Proper cleanup of git resources

Testing

The module includes comprehensive test coverage:

# Run all git tests
go test ./internal/git

# Run specific test suites
go test ./internal/git -run TestRepo_BranchOperations
go test ./internal/git -run TestRepo_MergeOperations
go test ./internal/git -run TestRepo_SecurityValidation
Test Categories
  • Unit Tests - Individual function testing
  • Integration Tests - Multi-function workflow testing
  • Security Tests - Input validation and injection prevention
  • Error Handling Tests - Error type and message validation
  • Performance Tests - Large repository handling

Migration Guide

From Monolithic git.go

The original 551-line git.go file has been split into focused modules:

  1. Branch Operationsrepo_branches.go
  2. Merge Operationsrepo_merges.go
  3. Remote Operationsrepo_remotes.go
  4. State Managementrepo_state.go
  5. Securitysanitizer.go, validator.go
Usage Changes

Before:

// Monolithic approach
gitRepo, err := git.OpenRepository(path)
if err != nil {
    return err
}
// All operations in one massive file

After:

// Modular approach
repo, err := git.OpenRepo(path)
if err != nil {
    return err
}
// Operations split into focused modules with proper error handling

Best Practices

  1. Always Validate Input - Use sanitizers before git operations
  2. Handle Errors Properly - Use structured error types for better debugging
  3. Check Repository State - Verify repository state before operations
  4. Use Safe Operations - Prefer force-with-lease over force pushes
  5. Test Thoroughly - Include edge cases and security scenarios
  6. Document Operations - Add context to errors for better debugging

Future Enhancements

  • Parallel Operations - Concurrent git operations where safe
  • Advanced Conflict Resolution - More sophisticated conflict handling
  • Performance Optimization - Further optimization for large repositories
  • Enhanced Security - Additional security validation patterns
  • Better Integration - Deeper integration with validation framework

This git operations module provides a solid, secure, and maintainable foundation for all git-related operations in the Hitch application.

Documentation

Overview

Package git provides Git repository operations and utilities for Hitch.

Overview

This package wraps the go-git library with Hitch-specific functionality, providing a higher-level interface for Git operations with enhanced safety, validation, and conflict handling.

Core Types

The main type is Repo, which wraps go-git's Repository:

type Repo struct {
    *git.Repository
    workdir string
}

Repo provides convenient methods for common Git operations while maintaining access to the underlying go-git functionality.

Key Components

The package consists of several focused components:

  • repo.go: Core repository operations (branch, checkout, merge, commit)
  • operations.go: Higher-level operations (force-with-lease push)
  • validator.go: Repository validation and health checks
  • sanitizer.go: Input sanitization for branch names and user input
  • conflict_handler.go: Merge conflict detection and handling

Repository Operations

Common repository operations:

// Open a repository
repo, err := git.OpenRepo(".")
if err != nil {
    return err
}

// Get current branch
branch, err := repo.CurrentBranch()

// Create and checkout a branch
err = repo.CreateBranch("feature/new", "main")
err = repo.Checkout("feature/new")

// Check for uncommitted changes
hasChanges, err := repo.HasUncommittedChanges("HEAD")

// Merge branches
err = repo.Merge("feature/branch", "Merge feature branch")

Input Sanitization

The InputSanitizer protects against command injection and invalid input:

sanitizer := git.NewInputSanitizer()

// Validate branch names
if !sanitizer.IsValidBranchName("feature/login") {
    return errors.New("invalid branch name")
}

// Sanitize environment names
env := sanitizer.SanitizeEnvironmentName("dev-123")

// Validate email addresses
if !sanitizer.IsValidEmail("[email protected]") {
    return errors.New("invalid email")
}

The sanitizer blocks:

  • Branch names with special characters (, ', ", `, ;, $, etc.)
  • Environment names with path traversal attempts (../)
  • Invalid email addresses
  • Command injection attempts

Repository Validation

The RepositoryValidator performs comprehensive health checks:

validator := git.NewRepositoryValidator(repo)
result := validator.ValidateRepository()

if !result.IsValid {
    for _, err := range result.Errors {
        fmt.Println("Error:", err)
    }
    for _, warn := range result.Warnings {
        fmt.Println("Warning:", warn)
    }
}

Validation checks include:

  • Repository exists and is accessible
  • .git directory is present and valid
  • HEAD reference exists
  • Working directory is clean (for operations requiring it)
  • No corrupted objects
  • Metadata branch (hitch-metadata) is properly configured

Conflict Handling

The ConflictHandler detects and reports merge conflicts:

handler := git.NewConflictHandler(repo)
result := handler.CheckForConflicts("feature/branch", "main")

if result.HasConflicts {
    fmt.Println("Conflicts detected:")
    for _, file := range result.ConflictingFiles {
        fmt.Printf("  - %s\n", file)
    }
}

Force-with-Lease

Safe force pushing with lease validation:

err := repo.ForcePushWithLease("dev", "origin/dev", "abc123")

This ensures:

  • Remote branch hasn't been updated by others
  • Local changes won't overwrite unexpected commits
  • Safe force push for environment rebuilds

Branch Operations

Comprehensive branch management:

// Check if branch exists
exists := repo.BranchExists("feature/login")

// Get all branches
branches, err := repo.Branches()

// Delete branch
err = repo.DeleteBranch("feature/old", false) // safe delete
err = repo.DeleteBranch("feature/old", true)  // force delete

// Get branch creation time
createdAt, err := repo.BranchCreatedAt("feature/login")

// Check if branch is merged
merged, err := repo.IsBranchMerged("feature/login", "main")

User Information

Extract Git user configuration:

name, err := repo.UserName()
email, err := repo.UserEmail()

Working Directory

Access to repository paths:

workdir := repo.WorkingTree()
gitDir := filepath.Join(workdir, ".git")

Safety Features

The package implements multiple safety mechanisms:

  • Input validation before any git commands
  • Sanitization of all user-provided strings
  • Pre-flight checks for repository state
  • Conflict detection before merges
  • Force-with-lease for safe force pushes
  • Comprehensive error messages

Error Handling

All functions return descriptive errors:

err := repo.Merge("feature/branch", "Merge message")
if err != nil {
    // Error includes context about what failed
    return fmt.Errorf("merge failed: %w", err)
}

Testing

The package includes extensive tests:

  • sanitizer_test.go: Input sanitization tests
  • sanitizer_edge_cases_test.go: Edge cases and attack vectors
  • conflict_handler_test.go: Merge conflict detection
  • validator_test.go: Repository validation
  • force_with_lease_test.go: Safe force push operations
  • repo_test.go: Core repository operations

All tests use isolated environments (enforced globally).

Dependencies

External dependencies:

  • github.com/go-git/go-git/v5: Pure Go Git implementation

Internal dependencies:

  • None (this is a foundational package)

Example: Complete Workflow

// Open repository
repo, err := git.OpenRepo(".")
if err != nil {
    return err
}

// Validate repository state
validator := git.NewRepositoryValidator(repo)
if result := validator.ValidateRepository(); !result.IsValid {
    return fmt.Errorf("repository validation failed")
}

// Sanitize input
sanitizer := git.NewInputSanitizer()
if !sanitizer.IsValidBranchName(branchName) {
    return fmt.Errorf("invalid branch name: %s", branchName)
}

// Check for conflicts
conflictHandler := git.NewConflictHandler(repo)
result := conflictHandler.CheckForConflicts(branchName, "main")
if result.HasConflicts {
    return fmt.Errorf("merge conflicts detected")
}

// Perform operation
err = repo.Merge(branchName, "Merge feature branch")
if err != nil {
    return err
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConflictHandler added in v0.1.21

type ConflictHandler struct {
	// contains filtered or unexported fields
}

ConflictHandler manages interactive merge conflict resolution

func NewConflictHandler added in v0.1.21

func NewConflictHandler(repo *Repo) *ConflictHandler

NewConflictHandler creates a new conflict handler

func (*ConflictHandler) ConfirmAction added in v0.1.21

func (ch *ConflictHandler) ConfirmAction(message string, defaultValue bool) bool

ConfirmAction asks for user confirmation with a custom message

func (*ConflictHandler) DetectConflicts added in v0.1.21

func (ch *ConflictHandler) DetectConflicts(sourceBranch, targetBranch string, mergeErr error) *MergeConflict

DetectConflicts analyzes a merge error to extract conflict information

func (*ConflictHandler) HandleConflict added in v0.1.21

func (ch *ConflictHandler) HandleConflict(conflict *MergeConflict) (ConflictResolution, error)

HandleConflict presents the interactive conflict resolution interface

func (*ConflictHandler) IsTerminal added in v0.1.21

func (ch *ConflictHandler) IsTerminal() bool

IsTerminal checks if we're running in an interactive terminal

type ConflictResolution added in v0.1.21

type ConflictResolution int

ConflictResolution represents the user's choice for conflict resolution

const (
	ResolutionRollback ConflictResolution = iota
	ResolutionPause
	ResolutionManual
)

type GitRepository added in v0.1.21

type GitRepository interface {
	// Core repository information
	WorkingTree() string
	CurrentBranch() (string, error)
	IsDetachedHead() bool
	CurrentCommitSHA() (string, error)
	IsGitRepository() bool

	// User configuration
	UserName() (string, error)
	UserEmail() (string, error)
	HasUncommittedChanges(branch string) (bool, error)
}

GitRepository defines the interface for git repository operations

type InputSanitizer added in v0.1.21

type InputSanitizer struct{}

InputSanitizer validates and sanitizes user inputs for git commands

func NewInputSanitizer added in v0.1.21

func NewInputSanitizer() *InputSanitizer

NewInputSanitizer creates a new input sanitizer

func (*InputSanitizer) SanitizeBranchName added in v0.1.21

func (s *InputSanitizer) SanitizeBranchName(branch string) error

SanitizeBranchName validates that a branch name is safe for git operations

func (*InputSanitizer) SanitizeCommitMessage added in v0.1.21

func (s *InputSanitizer) SanitizeCommitMessage(message string) error

SanitizeCommitMessage validates that a commit message is safe

func (*InputSanitizer) SanitizeEnvironmentVariable added in v0.1.21

func (s *InputSanitizer) SanitizeEnvironmentVariable(name, value string) error

SanitizeEnvironmentVariable validates that an environment variable name and value are safe

func (*InputSanitizer) SanitizeFileName added in v0.1.21

func (s *InputSanitizer) SanitizeFileName(filename string) error

SanitizeFileName validates that a filename is safe for git operations

func (*InputSanitizer) SanitizeRemoteName added in v0.1.21

func (s *InputSanitizer) SanitizeRemoteName(remote string) error

SanitizeRemoteName validates that a remote name is safe

func (*InputSanitizer) SanitizeURL added in v0.1.21

func (s *InputSanitizer) SanitizeURL(url string) error

SanitizeURL validates that a URL is safe for git operations

func (*InputSanitizer) ValidateGitConfigKey added in v0.1.21

func (s *InputSanitizer) ValidateGitConfigKey(key string) error

ValidateGitConfigKey validates that a git config key is safe

func (*InputSanitizer) ValidateGitConfigValue added in v0.1.21

func (s *InputSanitizer) ValidateGitConfigValue(value string) error

ValidateGitConfigValue validates that a git config value is safe

func (*InputSanitizer) ValidateRef added in v0.1.21

func (s *InputSanitizer) ValidateRef(ref string) error

ValidateRef validates that a git reference is safe

type MergeConflict added in v0.1.21

type MergeConflict struct {
	SourceBranch     string
	TargetBranch     string
	ConflictingFiles []string
	OriginalError    error
	IsSquashMerge    bool
}

MergeConflict represents information about a merge conflict

type Repo

type Repo struct {
	*git.Repository
	// contains filtered or unexported fields
}

Repo wraps a git repository with helpful methods

func OpenRepo

func OpenRepo(path string) (*Repo, error)

OpenRepo opens a git repository at the given path

func (*Repo) BranchExists

func (r *Repo) BranchExists(name string) bool

BranchExists checks if a branch exists (local or remote)

func (*Repo) BranchExistsDetailed added in v1.1.12

func (r *Repo) BranchExistsDetailed(branchName string) (bool, error)

BranchExistsDetailed checks if a branch still exists (different return signature than existing method)

func (*Repo) CanMerge added in v0.1.21

func (r *Repo) CanMerge(branch string) (bool, error)

CanMerge checks if a merge would succeed without actually performing it

func (*Repo) Checkout

func (r *Repo) Checkout(ref string) error

Checkout checks out a branch or commit

func (*Repo) CreateBranch

func (r *Repo) CreateBranch(name string, fromRef string) error

CreateBranch creates a new branch

func (*Repo) CurrentBranch

func (r *Repo) CurrentBranch() (string, error)

CurrentBranch returns the name of the current branch

func (*Repo) CurrentCommitSHA

func (r *Repo) CurrentCommitSHA() (string, error)

CurrentCommitSHA returns the SHA of the current commit

func (*Repo) DeleteBranch

func (r *Repo) DeleteBranch(name string, force bool) error

DeleteBranch deletes a branch

func (*Repo) DeleteRemoteBranch

func (r *Repo) DeleteRemoteBranch(remoteName string, branchName string) error

DeleteRemoteBranch deletes a remote branch

func (*Repo) DetectForcePush added in v1.1.12

func (r *Repo) DetectForcePush(branchName, oldSHA string) (bool, error)

DetectForcePush checks if a branch has been force-pushed by checking if the old SHA still exists in its history

func (*Repo) DiffBranches added in v1.1.10

func (r *Repo) DiffBranches(branch1, branch2 string) (string, error)

DiffBranches gets the diff between two branches

func (*Repo) GetBranchCommitSHA added in v1.1.12

func (r *Repo) GetBranchCommitSHA(branchName string) (string, error)

GetBranchCommitSHA returns the current HEAD SHA for a specific branch

func (*Repo) GetBranches added in v1.1.8

func (r *Repo) GetBranches() ([]string, error)

GetBranches returns a list of all local branches

func (*Repo) GetBranchesMatching added in v1.1.8

func (r *Repo) GetBranchesMatching(pattern string) ([]string, error)

GetBranchesMatching returns branches that match the given pattern (supports wildcards)

func (*Repo) GetCommitsBetween added in v1.1.12

func (r *Repo) GetCommitsBetween(oldSHA, newSHA string) (int, error)

GetCommitsBetween returns the number of commits between two SHAs

func (*Repo) HasUncommittedChanges

func (r *Repo) HasUncommittedChanges(branch string) (bool, error)

HasUncommittedChanges checks if a branch has uncommitted changes Note: This requires executing git commands as go-git doesn't support this well

func (*Repo) IsDetachedHead

func (r *Repo) IsDetachedHead() bool

IsDetachedHead checks if HEAD is in detached state

func (*Repo) IsGitRepository added in v0.1.21

func (r *Repo) IsGitRepository() bool

IsGitRepository checks if the current directory is a git repository

func (*Repo) IsMergeInProgress added in v0.1.21

func (r *Repo) IsMergeInProgress() bool

IsMergeInProgress checks if there's an ongoing merge operation

func (*Repo) Merge

func (r *Repo) Merge(branch string, message string) error

Merge merges a branch into the current branch with an optional message Note: This uses git command as go-git's merge support is limited

func (*Repo) MergeAbort

func (r *Repo) MergeAbort() error

MergeAbort aborts an in-progress merge

func (*Repo) MergeBase added in v1.1.10

func (r *Repo) MergeBase(branch1, branch2 string) (string, error)

MergeBase finds the common ancestor between two branches

func (*Repo) MergeSquash

func (r *Repo) MergeSquash(branch string, message string) error

MergeSquash squash merges a branch into the current branch

func (*Repo) Pull

func (r *Repo) Pull(remoteName string, branchName string) error

Pull pulls changes from remote

func (*Repo) Push

func (r *Repo) Push(remoteName string, branchName string, force bool) error

Push pushes changes to remote Uses force-with-lease for safety when force is specified

func (*Repo) UserEmail

func (r *Repo) UserEmail() (string, error)

UserEmail returns the configured git user email

func (*Repo) UserName

func (r *Repo) UserName() (string, error)

UserName returns the configured git user name

func (*Repo) WorkingTree added in v0.1.7

func (r *Repo) WorkingTree() string

WorkingTree returns the working directory path of the repository

type RepositoryLock added in v1.1.10

type RepositoryLock struct {
	// contains filtered or unexported fields
}

RepositoryLock provides cross-process synchronization for Git operations

func GetRepositoryLock added in v1.1.10

func GetRepositoryLock(repoPath string) *RepositoryLock

GetRepositoryLock returns a repository lock for the given path

func NewRepositoryLock added in v1.1.10

func NewRepositoryLock(repoPath string) *RepositoryLock

NewRepositoryLock creates a new repository lock for the given path

func (*RepositoryLock) Lock added in v1.1.10

func (rl *RepositoryLock) Lock() error

Lock acquires exclusive access to the repository for Git operations

func (*RepositoryLock) Unlock added in v1.1.10

func (rl *RepositoryLock) Unlock() error

Unlock releases the repository lock

func (*RepositoryLock) WithLock added in v1.1.10

func (rl *RepositoryLock) WithLock(fn func() error) error

WithLock executes a function while holding the repository lock

type RepositoryValidator added in v0.1.21

type RepositoryValidator struct {
	// contains filtered or unexported fields
}

RepositoryValidator checks repository health and integrity

func NewRepositoryValidator added in v0.1.21

func NewRepositoryValidator(repo *Repo) *RepositoryValidator

NewRepositoryValidator creates a new repository validator

func (*RepositoryValidator) ValidateRepository added in v0.1.21

func (v *RepositoryValidator) ValidateRepository() ValidationResult

ValidateRepository performs comprehensive repository validation

type ValidationResult added in v0.1.21

type ValidationResult struct {
	IsHealthy bool
	Issues    []string
	Warnings  []string
}

ValidationResult contains the result of repository validation

Jump to

Keyboard shortcuts

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