git

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package git provides git repository operations using go-git library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Platform

type Platform string

Platform represents a git hosting platform.

const (
	// PlatformGitLab represents GitLab hosting.
	PlatformGitLab Platform = "gitlab"
	// PlatformGitHub represents GitHub hosting.
	PlatformGitHub Platform = "github"
)

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 *bullets.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).

Jump to

Keyboard shortcuts

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