git

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: GPL-3.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git provides Git operations and error definitions.

Package git is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGitCommandFailed       = errors.New("git command failed")
	ErrBranchNotFound         = errors.New("branch not found")
	ErrWorktreeExists         = errors.New("worktree already exists")
	ErrWorktreeNotFound       = errors.New("worktree not found")
	ErrWorktreeDeletionFailed = errors.New("failed to delete worktree")
	ErrWorktreePathNotFound   = errors.New("worktree path not found")
	ErrRepositoryNotClean     = errors.New("repository is not clean")
	ErrRemoteOriginNotFound   = errors.New("remote origin not found")
	ErrRemoteNotFound         = errors.New("remote not found")
	ErrRemoteAddFailed        = errors.New("failed to add remote")
	ErrFetchFailed            = errors.New("failed to fetch from remote")
	ErrBranchNotFoundOnRemote = errors.New("branch not found on remote")
)

Git-specific error types.

Functions

This section is empty.

Types

type BranchExistsOnRemoteParams

type BranchExistsOnRemoteParams struct {
	RepoPath   string
	RemoteName string
	Branch     string
}

BranchExistsOnRemoteParams contains parameters for BranchExistsOnRemote.

type CloneParams

type CloneParams struct {
	RepoURL    string
	TargetPath string
	Recursive  bool
}

CloneParams contains parameters for Clone.

type Git

type Git interface {
	// Status executes `git status` in specified directory.
	Status(workDir string) (string, error)

	// ConfigGet executes `git config --get <key>` in specified directory.
	ConfigGet(workDir, key string) (string, error)

	// CreateWorktree creates a new worktree for the specified branch.
	CreateWorktree(repoPath, worktreePath, branch string) error

	// GetCurrentBranch gets the current branch name.
	GetCurrentBranch(repoPath string) (string, error)

	// GetRepositoryName gets the repository name from remote origin URL with fallback to local path.
	GetRepositoryName(repoPath string) (string, error)

	// IsClean checks if the repository is in a clean state (placeholder for future validation).
	IsClean(repoPath string) (bool, error)

	// BranchExists checks if a branch exists locally or remotely.
	BranchExists(repoPath, branch string) (bool, error)

	// CreateBranch creates a new branch from the current branch.
	CreateBranch(repoPath, branch string) error

	// WorktreeExists checks if a worktree exists for the specified branch.
	WorktreeExists(repoPath, branch string) (bool, error)

	// RemoveWorktree removes a worktree from Git's tracking.
	RemoveWorktree(repoPath, worktreePath string) error

	// GetWorktreePath gets the path of a worktree for a branch.
	GetWorktreePath(repoPath, branch string) (string, error)

	// AddRemote adds a new remote to the repository.
	AddRemote(repoPath, remoteName, remoteURL string) error

	// FetchRemote fetches from a specific remote.
	FetchRemote(repoPath, remoteName string) error

	// BranchExistsOnRemote checks if a branch exists on a specific remote.
	BranchExistsOnRemote(params BranchExistsOnRemoteParams) (bool, error)

	// GetRemoteURL gets the URL of a remote.
	GetRemoteURL(repoPath, remoteName string) (string, error)

	// RemoteExists checks if a remote exists.
	RemoteExists(repoPath, remoteName string) (bool, error)

	// GetBranchRemote gets the remote name for a branch (e.g., "origin", "justenstall").
	GetBranchRemote(repoPath, branch string) (string, error)

	// Add adds files to the Git staging area.
	Add(repoPath string, files ...string) error

	// Commit creates a new commit with the specified message.
	Commit(repoPath, message string) error

	// Clone clones a repository to the specified path.
	Clone(params CloneParams) error

	// GetDefaultBranch gets the default branch name from a remote repository.
	GetDefaultBranch(remoteURL string) (string, error)
}

Git interface provides Git command execution capabilities.

func NewGit

func NewGit() Git

NewGit creates a new Git instance.

type MockGit

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

MockGit is a mock of Git interface.

func NewMockGit

func NewMockGit(ctrl *gomock.Controller) *MockGit

NewMockGit creates a new mock instance.

func (*MockGit) Add

func (m *MockGit) Add(repoPath string, files ...string) error

Add mocks base method.

func (*MockGit) AddRemote

func (m *MockGit) AddRemote(repoPath, remoteName, remoteURL string) error

AddRemote mocks base method.

func (*MockGit) BranchExists

func (m *MockGit) BranchExists(repoPath, branch string) (bool, error)

BranchExists mocks base method.

func (*MockGit) BranchExistsOnRemote

func (m *MockGit) BranchExistsOnRemote(params BranchExistsOnRemoteParams) (bool, error)

BranchExistsOnRemote mocks base method.

func (*MockGit) Clone

func (m *MockGit) Clone(params CloneParams) error

Clone mocks base method.

func (*MockGit) Commit

func (m *MockGit) Commit(repoPath, message string) error

Commit mocks base method.

func (*MockGit) ConfigGet

func (m *MockGit) ConfigGet(workDir, key string) (string, error)

ConfigGet mocks base method.

func (*MockGit) CreateBranch

func (m *MockGit) CreateBranch(repoPath, branch string) error

CreateBranch mocks base method.

func (*MockGit) CreateWorktree

func (m *MockGit) CreateWorktree(repoPath, worktreePath, branch string) error

CreateWorktree mocks base method.

func (*MockGit) EXPECT

func (m *MockGit) EXPECT() *MockGitMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGit) FetchRemote

func (m *MockGit) FetchRemote(repoPath, remoteName string) error

FetchRemote mocks base method.

func (*MockGit) GetBranchRemote

func (m *MockGit) GetBranchRemote(repoPath, branch string) (string, error)

GetBranchRemote mocks base method.

func (*MockGit) GetCurrentBranch

func (m *MockGit) GetCurrentBranch(repoPath string) (string, error)

GetCurrentBranch mocks base method.

func (*MockGit) GetDefaultBranch

func (m *MockGit) GetDefaultBranch(remoteURL string) (string, error)

GetDefaultBranch mocks base method.

func (*MockGit) GetRemoteURL

func (m *MockGit) GetRemoteURL(repoPath, remoteName string) (string, error)

GetRemoteURL mocks base method.

func (*MockGit) GetRepositoryName

func (m *MockGit) GetRepositoryName(repoPath string) (string, error)

GetRepositoryName mocks base method.

func (*MockGit) GetWorktreePath

func (m *MockGit) GetWorktreePath(repoPath, branch string) (string, error)

GetWorktreePath mocks base method.

func (*MockGit) IsClean

func (m *MockGit) IsClean(repoPath string) (bool, error)

IsClean mocks base method.

func (*MockGit) RemoteExists

func (m *MockGit) RemoteExists(repoPath, remoteName string) (bool, error)

RemoteExists mocks base method.

func (*MockGit) RemoveWorktree

func (m *MockGit) RemoveWorktree(repoPath, worktreePath string) error

RemoveWorktree mocks base method.

func (*MockGit) Status

func (m *MockGit) Status(workDir string) (string, error)

Status mocks base method.

func (*MockGit) WorktreeExists

func (m *MockGit) WorktreeExists(repoPath, branch string) (bool, error)

WorktreeExists mocks base method.

type MockGitMockRecorder

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

MockGitMockRecorder is the mock recorder for MockGit.

func (*MockGitMockRecorder) Add

func (mr *MockGitMockRecorder) Add(repoPath any, files ...any) *gomock.Call

Add indicates an expected call of Add.

func (*MockGitMockRecorder) AddRemote

func (mr *MockGitMockRecorder) AddRemote(repoPath, remoteName, remoteURL any) *gomock.Call

AddRemote indicates an expected call of AddRemote.

func (*MockGitMockRecorder) BranchExists

func (mr *MockGitMockRecorder) BranchExists(repoPath, branch any) *gomock.Call

BranchExists indicates an expected call of BranchExists.

func (*MockGitMockRecorder) BranchExistsOnRemote

func (mr *MockGitMockRecorder) BranchExistsOnRemote(params any) *gomock.Call

BranchExistsOnRemote indicates an expected call of BranchExistsOnRemote.

func (*MockGitMockRecorder) Clone

func (mr *MockGitMockRecorder) Clone(params any) *gomock.Call

Clone indicates an expected call of Clone.

func (*MockGitMockRecorder) Commit

func (mr *MockGitMockRecorder) Commit(repoPath, message any) *gomock.Call

Commit indicates an expected call of Commit.

func (*MockGitMockRecorder) ConfigGet

func (mr *MockGitMockRecorder) ConfigGet(workDir, key any) *gomock.Call

ConfigGet indicates an expected call of ConfigGet.

func (*MockGitMockRecorder) CreateBranch

func (mr *MockGitMockRecorder) CreateBranch(repoPath, branch any) *gomock.Call

CreateBranch indicates an expected call of CreateBranch.

func (*MockGitMockRecorder) CreateWorktree

func (mr *MockGitMockRecorder) CreateWorktree(repoPath, worktreePath, branch any) *gomock.Call

CreateWorktree indicates an expected call of CreateWorktree.

func (*MockGitMockRecorder) FetchRemote

func (mr *MockGitMockRecorder) FetchRemote(repoPath, remoteName any) *gomock.Call

FetchRemote indicates an expected call of FetchRemote.

func (*MockGitMockRecorder) GetBranchRemote

func (mr *MockGitMockRecorder) GetBranchRemote(repoPath, branch any) *gomock.Call

GetBranchRemote indicates an expected call of GetBranchRemote.

func (*MockGitMockRecorder) GetCurrentBranch

func (mr *MockGitMockRecorder) GetCurrentBranch(repoPath any) *gomock.Call

GetCurrentBranch indicates an expected call of GetCurrentBranch.

func (*MockGitMockRecorder) GetDefaultBranch

func (mr *MockGitMockRecorder) GetDefaultBranch(remoteURL any) *gomock.Call

GetDefaultBranch indicates an expected call of GetDefaultBranch.

func (*MockGitMockRecorder) GetRemoteURL

func (mr *MockGitMockRecorder) GetRemoteURL(repoPath, remoteName any) *gomock.Call

GetRemoteURL indicates an expected call of GetRemoteURL.

func (*MockGitMockRecorder) GetRepositoryName

func (mr *MockGitMockRecorder) GetRepositoryName(repoPath any) *gomock.Call

GetRepositoryName indicates an expected call of GetRepositoryName.

func (*MockGitMockRecorder) GetWorktreePath

func (mr *MockGitMockRecorder) GetWorktreePath(repoPath, branch any) *gomock.Call

GetWorktreePath indicates an expected call of GetWorktreePath.

func (*MockGitMockRecorder) IsClean

func (mr *MockGitMockRecorder) IsClean(repoPath any) *gomock.Call

IsClean indicates an expected call of IsClean.

func (*MockGitMockRecorder) RemoteExists

func (mr *MockGitMockRecorder) RemoteExists(repoPath, remoteName any) *gomock.Call

RemoteExists indicates an expected call of RemoteExists.

func (*MockGitMockRecorder) RemoveWorktree

func (mr *MockGitMockRecorder) RemoveWorktree(repoPath, worktreePath any) *gomock.Call

RemoveWorktree indicates an expected call of RemoveWorktree.

func (*MockGitMockRecorder) Status

func (mr *MockGitMockRecorder) Status(workDir any) *gomock.Call

Status indicates an expected call of Status.

func (*MockGitMockRecorder) WorktreeExists

func (mr *MockGitMockRecorder) WorktreeExists(repoPath, branch any) *gomock.Call

WorktreeExists indicates an expected call of WorktreeExists.

Jump to

Keyboard shortcuts

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