Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectBranch ¶ added in v0.16.1
DetectBranch returns the current branch name (`git rev-parse --abbrev-ref HEAD`) for the given cwd, or "" on error. Detached HEAD returns the literal string "HEAD".
func DetectTrackingRemote ¶ added in v0.16.1
DetectTrackingRemote returns the value of branch.<branch>.remote git config for the given cwd, or "" when unset / on any error. Silent. branch == "" short-circuits to "" without invoking git.
func GetHeadSHA ¶
GetHeadSHA returns the full SHA of the HEAD commit. Returns empty string and nil if not in a git repo.
func GetRepoURL ¶
GetRepoURL returns the remote origin URL for a git repository Returns empty string if not a git repo or no remote configured
func ToGitHubURL ¶
ToGitHubURL converts a git remote URL to a GitHub HTTPS URL. Handles: git@github.com:owner/repo.git, https://github.com/owner/repo.git, ssh://git@github.com/owner/repo.git Returns empty string if not a GitHub URL.
Types ¶
type GitInfo ¶
type GitInfo struct {
RepoURL string `json:"repo_url,omitempty"`
Branch string `json:"branch,omitempty"`
CommitSHA string `json:"commit_sha,omitempty"`
CommitMessage string `json:"commit_message,omitempty"`
Author string `json:"author,omitempty"`
IsDirty bool `json:"is_dirty"`
Remotes []GitRemote `json:"remotes,omitempty"`
TrackingRemote string `json:"tracking_remote,omitempty"`
}
GitInfo contains git repository information
func DetectGitInfo ¶
DetectGitInfo detects git information from the given directory Returns nil if not in a git repository (this is not an error)
func ExtractGitInfoFromTranscript ¶
ExtractGitInfoFromTranscript parses a Claude Code transcript file to extract git information This is useful for uploading sessions where the original directory may not exist
type GitRemote ¶ added in v0.16.1
type GitRemote struct {
Name string `json:"name"`
FetchURL string `json:"fetch_url"`
PushURL string `json:"push_url"`
}
GitRemote describes a single git remote (one entry in `git remote -v`, merging the (fetch) and (push) lines). JSON tags mirror CF-494's db.GitRemote exactly — no omitempty on URL fields, since the CLI always emits both per the locked wire-format decision.
func DetectRemotes ¶ added in v0.16.1
DetectRemotes returns the configured git remotes for cwd. Returns (nil, nil) when cwd is not a git repo or when git is unavailable — silent best-effort, matching GetRepoURL's pattern.