Documentation
¶
Index ¶
- func ExecPath(ctx context.Context) (string, error)
- type Client
- func (c *Client) Authors() ([]string, error)
- func (c *Client) Commit(ctx context.Context, msg []byte, opts CommitOptions) (CommitSummary, error)
- func (c *Client) CreateBranch(name, baseBranch string) error
- func (c *Client) CurrentBranch() (string, error)
- func (c *Client) DefaultBaseBranch() (string, error)
- func (c *Client) DeleteLocalBranch(ctx context.Context, name string, force bool) error
- func (c *Client) IsMergedInto(branchName, baseBranch string) (bool, error)
- func (c *Client) LocalBranchNames() ([]string, error)
- func (c *Client) MergeDryRun(ctx context.Context, branchName, baseBranch string) ([]string, error)
- func (c *Client) MergeNoFF(ctx context.Context, branchName, baseBranch string) error
- func (c *Client) MergeSquash(ctx context.Context, branchName, baseBranch, author string) error
- func (c *Client) WorkingTreeRoot() (string, error)
- type CommitOptions
- type CommitSummary
- type IO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a go-git repository and exposes commit operations.
func NewClient ¶
NewClient opens the git repository that contains the current directory. ioStreams configures the streams used for interactive operations; nil uses os.Stdin/Stdout/Stderr.
func NewClientAt ¶ added in v0.4.2
NewClientAt opens the git repository rooted at dir. ioStreams configures the streams used for interactive operations; nil uses os.Stdin/Stdout/Stderr.
func (*Client) Authors ¶
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(ctx context.Context, msg []byte, opts CommitOptions) (CommitSummary, error)
Commit records a commit with msg and the given options using the system git binary so that all configured hooks (pre-commit, commit-msg, post-commit) run. It returns a CommitSummary suitable for printing to the user.
func (*Client) CreateBranch ¶
CreateBranch creates a new branch from baseBranch and checks it out.
func (*Client) CurrentBranch ¶ added in v0.4.2
CurrentBranch returns the short name of the branch HEAD points to. On a detached HEAD the returned name will not parse as an issue branch, so callers can simply ignore it.
func (*Client) DefaultBaseBranch ¶
DefaultBaseBranch resolves the default base branch in priority order:
- refs/remotes/origin/HEAD
- "main" if the local ref exists
- "master" if the local ref exists
func (*Client) DeleteLocalBranch ¶ added in v0.4.2
DeleteLocalBranch deletes the local branch by name. force=true uses -D (required after squash merges); force=false uses -d (safe).
func (*Client) IsMergedInto ¶
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 ¶
LocalBranchNames returns the short names of all local branches.
func (*Client) MergeDryRun ¶ added in v0.4.2
MergeDryRun checks whether branchName merges cleanly into baseBranch. It performs the check in a temporary git worktree so the main working tree is never modified. Returns the list of conflicting file paths, or nil if clean.
func (*Client) MergeNoFF ¶ added in v0.4.2
MergeNoFF runs a classic --no-ff merge of branchName into baseBranch. After the merge the working directory is on baseBranch.
func (*Client) MergeSquash ¶ added in v0.4.2
MergeSquash squash-merges branchName into baseBranch and commits. author is "Name <email>"; if empty the git config identity is used. After the merge the working directory is on baseBranch.
func (*Client) WorkingTreeRoot ¶
WorkingTreeRoot returns the absolute path of the repository's working tree root.
type CommitOptions ¶
type CommitOptions struct {
All bool
Amend bool
NoVerify bool
Signoff bool
AllowEmpty bool
Author string // "Name <email>"; empty = git config identity
}
CommitOptions configures Client.Commit.