{"modulePath":"github.com/nuitsjp/commit-spark","version":"v0.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package git\n\nPackage git wraps the git CLI operations that commit-spark needs.\n\nA 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.\n\n## Types\n\n```go\ntype Client struct {\n\tDir            string\n\tStdout, Stderr io.Writer\n}\n```\nClient runs git commands.\n\n```go\nfunc (c *Client) Commit(ctx context.Context, message string) error\n```\nCommit runs git commit -m message.\n\n```go\nfunc (c *Client) CurrentBranch(ctx context.Context) (string, error)\n```\nCurrentBranch returns the current branch name (empty when detached).\n\n```go\nfunc (c *Client) DefaultBranch(ctx context.Context) (string, error)\n```\nDefaultBranch 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.\n\n```go\nfunc (c *Client) DiffRange(ctx context.Context, rangeSpec string) (string, error)\n```\nDiffRange returns the diff for the given range specification (e.g. \"origin/main..HEAD\").\n\n```go\nfunc (c *Client) Push(ctx context.Context) error\n```\nPush runs git push.\n\n```go\nfunc (c *Client) PushUpstream(ctx context.Context, branch string) error\n```\nPushUpstream runs git push -u origin \\\u003cbranch\u003e.\n\n```go\nfunc (c *Client) RemoteURL(ctx context.Context, name string) (string, error)\n```\nRemoteURL returns the URL of the named remote.\n\n```go\nfunc (c *Client) RepoRoot(ctx context.Context) (string, error)\n```\nRepoRoot returns the repository root (git rev-parse --show-toplevel).\n\n```go\nfunc (c *Client) StageAll(ctx context.Context) error\n```\nStageAll runs git add --all.\n\n```go\nfunc (c *Client) StagedDiff(ctx context.Context, excludeFiles []string) (*StagedDiff, error)\n```\nStagedDiff returns the staged diff (git diff --cached --diff-algorithm=minimal).\n\nLock 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.\n\n```go\ntype StagedDiff struct {\n\tFiles []string\n\tDiff  string\n}\n```\nStagedDiff is the result of StagedDiff: the retained file list and the diff text. An empty Files slice means nothing is staged.\n\n","path":"github.com/nuitsjp/commit-spark/internal/git","name":"git","synopsis":"Package git wraps the git CLI operations that commit-spark needs.","isRedistributable":true}
