Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package git replays revisions in a git working tree (vcs.Replayer) and creates signed commits in a git store (vcs.Signer).

Index

Constants

View Source
const (
	// RefPrefix is where a signing's commits are kept.
	RefPrefix = "refs/core-sign/"
	// StateDir is the directory of the common git directory that holds the
	// signings' records.
	StateDir = "core-sign"
)
View Source
const StateFile = "core-replay.json"

StateFile is the file in the worktree's git directory that holds a replay in progress.

Variables

This section is empty.

Functions

This section is empty.

Types

type Replayer

type Replayer struct {
	// Bin is the git executable; empty is "git".
	Bin string
}

Replayer replays revisions in a git working tree, one commit at a time with cherry-pick, with the working tree detached at the replay's tip: no branch is moved. Each replayed commit keeps its original's message, author and committer, so the same replay of the same commits onto the same revision gives the same commit ids, and a commit that is or becomes empty is kept, so the caller's commit boundaries stay. A replay that stops on a conflict leaves it in the working tree for the caller to resolve, and its state in the worktree's git directory (StateFile). Replay refuses a working tree with changes to tracked files.

The zero Replayer runs "git" from PATH. It fetches and pushes nothing.

func (Replayer) Abort

func (g Replayer) Abort(ctx context.Context, ws vcs.Workspace) error

Abort drops a stopped cherry-pick, returns HEAD to what it was before the replay and forgets the replay. The commits it made are left to git's garbage collection.

func (Replayer) Continue

func (g Replayer) Continue(ctx context.Context, ws vcs.Workspace) (vcs.Replay, error)

Continue stages the working tree, refuses a conflicted path that still holds a conflict marker, commits the stopped commit with its original's message, author and committer, and replays the rest.

func (Replayer) Replay

func (g Replayer) Replay(ctx context.Context, ws vcs.Workspace, req vcs.ReplayRequest) (vcs.Replay, error)

Replay detaches the working tree at req.Onto and replays the commits of req.OldBase..req.Head onto it.

func (Replayer) ReplayStatus

func (g Replayer) ReplayStatus(ctx context.Context, ws vcs.Workspace) (vcs.Replay, error)

ReplayStatus reads the replay in progress.

type Signer

type Signer struct {
	// Bin is the git executable; empty is "git".
	Bin string
}

Signer creates signed commits with `git commit-tree -S`, in any git store: a working tree, a bare repository, or the git store a Jujutsu repository shares, colocated or under .jj/repo/store/git. The author and the committer are the repository's configured identity (user.name and user.email, or author.* and committer.*), and the signature is made with its signing key and format (user.signingKey, gpg.format and the gpg.*program the format names). An identity that is not configured is refused rather than guessed, and GIT_AUTHOR_* and GIT_COMMITTER_* in the process's environment are ignored. A commit whose object carries no signature is never recorded, so a misconfigured signer fails Sign.

Commit i of a signing is kept under the ref RefPrefix<id>/<i>, which no branch, tag or Jujutsu bookmark is, and the signing's record is StateDir/<id>.json in the repository's common git directory, written after each commit. A commit created and kept under its ref before the record said so is taken up by the next Sign or SignStatus once its tree, parents, message and signature are checked, so nothing is signed twice.

The zero Signer runs "git" from PATH. It fetches and pushes nothing, and runs no hook.

func (Signer) Forget

func (g Signer) Forget(ctx context.Context, ws vcs.Workspace, id string) error

Forget deletes the refs of the signing recorded under id, then its record.

func (Signer) Sign

func (g Signer) Sign(ctx context.Context, ws vcs.Workspace, req vcs.SignRequest) (vcs.Signing, error)

Sign creates the commits of req, signed, taking up what a signing under req.ID created before.

func (Signer) SignStatus

func (g Signer) SignStatus(ctx context.Context, ws vcs.Workspace, id string) (vcs.Signing, error)

SignStatus reports the signing recorded under id, with any commit kept under its ref that the record does not say yet.

Jump to

Keyboard shortcuts

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