git

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package git is the production git adapter for the sdd binary: every git subprocess sdd runs is implemented here, behind the narrow interfaces its consumers define (handlers.Committer/Brancher/Mover/Puller, finders.GitSyncer, the repos package's clone/pull surface). Interfaces stay with their consumers; this package only provides the implementations, so a future — possibly partial — swap to an in-process implementation such as go-git touches nothing but this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteURL

func RemoteURL(repoRoot string) string

RemoteURL returns the repo's origin remote URL, or "" when no remote is configured — the local-only case for repo_id derivation.

func RepoRoot

func RepoRoot() (string, error)

RepoRoot returns the git repository root, falling back to cwd when not in a repository.

func UserName

func UserName() string

UserName reads git config user.name, returning an empty string when git is unavailable or the setting isn't configured. Best-effort — used only as a pre-filled default for the sdd init participant prompt.

Types

type CLI

type CLI struct{}

CLI is the exec-based adapter: a zero-value struct whose methods shell out to the git binary. One value satisfies the consumer-defined git interfaces (handlers.Committer/Brancher/Mover/Puller, finders.GitSyncer, repos.Git); the one exception is the staged-deletion commit variant, which shares the Commit method name and therefore lives on its own type (RemovalCommitter).

func (CLI) BranchMerged

func (CLI) BranchMerged(branch string) bool

BranchMerged reports whether branch is merged into the current HEAD.

func (CLI) Checkout

func (CLI) Checkout(branch string, create bool) error

Checkout switches to branch, creating it first when create is set. Production handlers.Brancher.

func (CLI) Clone

func (CLI) Clone(ctx context.Context, url, dir string) error

Clone clones url into dir.

func (CLI) Commit

func (CLI) Commit(message string, paths ...string) error

Commit stages exactly the given paths and commits them, detached from any controlling terminal. It is the production handlers.Committer for the auto-commit paths (sdd new, summarize, init, ...).

func (CLI) CountCommits

func (CLI) CountCommits(ctx context.Context, rangeSpec, grepPattern string) (int, error)

CountCommits counts commits in rangeSpec whose messages match grepPattern.

func (CLI) DeleteBranch

func (CLI) DeleteBranch(branch string, force bool) error

DeleteBranch removes branch (-d, or -D when force is set).

func (CLI) Fetch

func (CLI) Fetch(ctx context.Context) error

Fetch runs `git fetch` with no args.

func (CLI) HasCommitMessage added in v0.16.0

func (CLI) HasCommitMessage(ctx context.Context, text string) (bool, error)

HasCommitMessage reports whether any reachable commit contains text. It is used by retryable post-apply finalizers to recognize a commit that landed before its durable finalizer outcome could be recorded.

func (CLI) HasRemote

func (CLI) HasRemote(ctx context.Context) bool

HasRemote reports whether the repository has at least one remote configured.

func (CLI) InRepo

func (CLI) InRepo(ctx context.Context) bool

InRepo reports whether the process is inside a git working tree.

func (CLI) IsClean

func (CLI) IsClean(ctx context.Context) (bool, error)

IsClean reports whether the working tree has no uncommitted changes. Production handlers.Puller.

func (CLI) MergePull

func (CLI) MergePull(ctx context.Context) (string, error)

MergePull runs a merge-only pull. --no-rebase forces a merge pull regardless of the user's pull.rebase config, so background sync never rewrites the shared graph's history.

func (CLI) MergeTreePredict

func (CLI) MergeTreePredict(ctx context.Context, ourRef, theirRef string) ([]string, error)

MergeTreePredict simulates a three-way merge in memory and returns the paths that would conflict.

func (CLI) Move

func (CLI) Move(src, dst string) error

Move renames a path in the working tree and the git index as one operation via `git mv`, so the rename is recorded atomically with the working-tree change. Production handlers.Mover.

func (CLI) PullFFOnly

func (CLI) PullFFOnly(ctx context.Context, dir string) error

PullFFOnly pulls the checkout at dir, fast-forward only — the caches are read-only, so a non-ff state means the remote rewrote history; that surfaces as the error rather than merging.

func (CLI) UpstreamRef

func (CLI) UpstreamRef(ctx context.Context) (string, error)

UpstreamRef returns the upstream ref name for the current branch.

type RemovalCommitter

type RemovalCommitter struct{}

RemovalCommitter is the handlers.Committer variant for paths already removed from disk: it stages the deletions (`git rm --cached`, falling back to `git add`) before committing. Used by FinishWIP, where the marker file is gone by the time the commit runs.

func (RemovalCommitter) Commit

func (RemovalCommitter) Commit(message string, paths ...string) error

Commit stages the deletion of the given paths and commits, scoped to those paths so an unrelated staged index isn't swept into the removal commit.

Jump to

Keyboard shortcuts

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