git

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps a go-git repository and exposes commit operations.

func NewClient

func NewClient() (*Client, error)

NewClient opens the git repository that contains the current directory.

func (*Client) Authors

func (c *Client) Authors() ([]string, error)

Authors returns a deduplicated, alphabetically sorted list of commit author strings ("Name <email>") from the repository history. The current git config identity is prepended as the first (default) entry.

func (*Client) Commit

func (c *Client) Commit(msg []byte, opts CommitOptions) (CommitSummary, error)

Commit records a commit with msg and the given options. It returns a CommitSummary suitable for printing to the user.

func (*Client) CreateBranch

func (c *Client) CreateBranch(name, baseBranch string) error

CreateBranch creates a new branch from baseBranch and checks it out.

func (*Client) DefaultBaseBranch

func (c *Client) DefaultBaseBranch() (string, error)

DefaultBaseBranch resolves the default base branch in priority order:

  1. refs/remotes/origin/HEAD
  2. "main" if the local ref exists
  3. "master" if the local ref exists

func (*Client) IsMergedInto

func (c *Client) IsMergedInto(branchName, baseBranch string) (bool, error)

IsMergedInto reports whether branchName's tip commit is reachable from baseBranch, i.e. whether the branch has been merged into base (mirrors git merge-base --is-ancestor).

func (*Client) LocalBranchNames

func (c *Client) LocalBranchNames() ([]string, error)

LocalBranchNames returns the short names of all local branches.

func (*Client) WorkingTreeRoot

func (c *Client) WorkingTreeRoot() (string, error)

WorkingTreeRoot returns the absolute path of the repository's working tree root.

type CommitOptions

type CommitOptions struct {
	All   bool
	Amend bool
	// NoVerify — go-git v6 does not execute hooks; reserved for a future subprocess fallback.
	NoVerify   bool
	Signoff    bool
	AllowEmpty bool
	Author     string // "Name <email>"; empty = git config identity
}

CommitOptions configures Client.Commit.

type CommitSummary

type CommitSummary struct {
	ShortHash string
	Branch    string
	IsRoot    bool
	Subject   string
	Files     int
	Additions int
	Deletions int
}

CommitSummary holds display information about a newly created commit.

Jump to

Keyboard shortcuts

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