Documentation
¶
Overview ¶
Package git wraps the git CLI operations that commit-spark needs.
A Client executes git in its Dir (empty means the process's current directory, which is the normal case; tests set Dir to a temp repository). Query methods capture output and return it; the passthrough methods (StageAll, Commit, Push, PushUpstream) stream git's stdout/stderr to the Client's writers so hooks and commit summaries appear live.
Index ¶
- type Client
- func (c *Client) Commit(ctx context.Context, message string) error
- func (c *Client) CurrentBranch(ctx context.Context) (string, error)
- func (c *Client) DefaultBranch(ctx context.Context) (string, error)
- func (c *Client) DiffRange(ctx context.Context, rangeSpec string) (string, error)
- func (c *Client) Push(ctx context.Context) error
- func (c *Client) PushUpstream(ctx context.Context, branch string) error
- func (c *Client) RemoteURL(ctx context.Context, name string) (string, error)
- func (c *Client) RepoRoot(ctx context.Context) (string, error)
- func (c *Client) StageAll(ctx context.Context) error
- func (c *Client) StagedDiff(ctx context.Context, excludeFiles []string) (*StagedDiff, error)
- type StagedDiff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client runs git commands.
func (*Client) CurrentBranch ¶
CurrentBranch returns the current branch name (empty when detached).
func (*Client) DefaultBranch ¶
DefaultBranch returns the remote's default branch via symbolic-ref refs/remotes/origin/HEAD. It errors when origin/HEAD is unset (common for a repo created with only `git remote add`); the caller decides on a fallback.
func (*Client) DiffRange ¶
DiffRange returns the diff for the given range specification (e.g. "origin/main..HEAD").
func (*Client) PushUpstream ¶
PushUpstream runs git push -u origin <branch>.
func (*Client) StagedDiff ¶
StagedDiff returns the staged diff (git diff --cached --diff-algorithm=minimal).
Lock files are auto-excluded the same way the original implementation did: if any staged file is NOT a lock file, lock files (package-lock.json, pnpm-lock.yaml, *.lock) are excluded; if ALL staged files are lock files they are kept. excludeFiles are additional user-supplied pathspec exclusions. When nothing remains staged, the returned StagedDiff has an empty Files slice.
type StagedDiff ¶
StagedDiff is the result of StagedDiff: the retained file list and the diff text. An empty Files slice means nothing is staged.