Documentation
¶
Overview ¶
Package git provides git repository operations using go-git library.
Index ¶
- type Platform
- type Repository
- func (r *Repository) DeleteBranch(branchName string) error
- func (r *Repository) DetectPlatform() (Platform, error)
- func (r *Repository) FetchAndPrune() error
- func (r *Repository) GetCommitsSinceMain(mainBranch string) ([]*object.Commit, error)
- func (r *Repository) GetCurrentBranch() (string, error)
- func (r *Repository) GetLatestCommitMessage() (string, error)
- func (r *Repository) GetMainBranch() (string, error)
- func (r *Repository) GetRemoteURL(remoteName string) (string, error)
- func (r *Repository) HasStagedChanges() (bool, error)
- func (r *Repository) Pull() error
- func (r *Repository) PushBranch(branchName string) error
- func (r *Repository) SetLogger(logger *slog.Logger)
- func (r *Repository) SwitchBranch(branchName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository wraps a go-git repository with additional functionality.
func OpenRepository ¶
func OpenRepository(path string) (*Repository, error)
OpenRepository opens a git repository at the given path.
func (*Repository) DeleteBranch ¶
func (r *Repository) DeleteBranch(branchName string) error
DeleteBranch force-deletes the specified local branch using native git command.
func (*Repository) DetectPlatform ¶
func (r *Repository) DetectPlatform() (Platform, error)
DetectPlatform determines if the repository is hosted on GitLab or GitHub.
func (*Repository) FetchAndPrune ¶
func (r *Repository) FetchAndPrune() error
FetchAndPrune fetches from origin and prunes deleted remote branches using native git command.
func (*Repository) GetCommitsSinceMain ¶
func (r *Repository) GetCommitsSinceMain(mainBranch string) ([]*object.Commit, error)
GetCommitsSinceMain returns all commits on the current branch since it diverged from main.
func (*Repository) GetCurrentBranch ¶
func (r *Repository) GetCurrentBranch() (string, error)
GetCurrentBranch returns the name of the currently checked out branch.
func (*Repository) GetLatestCommitMessage ¶
func (r *Repository) GetLatestCommitMessage() (string, error)
GetLatestCommitMessage returns the commit message of the current HEAD.
func (*Repository) GetMainBranch ¶
func (r *Repository) GetMainBranch() (string, error)
GetMainBranch determines the main branch name (main or master).
func (*Repository) GetRemoteURL ¶
func (r *Repository) GetRemoteURL(remoteName string) (string, error)
GetRemoteURL returns the URL of the specified remote.
func (*Repository) HasStagedChanges ¶
func (r *Repository) HasStagedChanges() (bool, error)
HasStagedChanges checks if there are any staged changes in the repository.
func (*Repository) Pull ¶
func (r *Repository) Pull() error
Pull fetches and merges changes from the remote tracking branch using native git command.
func (*Repository) PushBranch ¶
func (r *Repository) PushBranch(branchName string) error
PushBranch pushes the specified branch to the origin remote.
func (*Repository) SetLogger ¶
func (r *Repository) SetLogger(logger *slog.Logger)
SetLogger sets the logger for the repository.
func (*Repository) SwitchBranch ¶
func (r *Repository) SwitchBranch(branchName string) error
SwitchBranch switches to the specified branch using native git command. This will fail if there are local changes that would conflict with the switch, forcing the user to handle conflicts manually (matching auto-mr.sh behavior).