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 deletes the specified local branch.
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.
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.
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 checks out the specified branch, allowing unstaged changes.