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

git

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package git implements loop.VCS by shelling out to git. It stages and commits the agent's changes and pushes the branch so a pull request can be opened against it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Git

type Git struct {
	// Bin is the git binary; defaults to "git".
	Bin string
	// Remote is the push remote; defaults to "origin".
	Remote string
	// AuthorName and AuthorEmail identify the committer. A GitHub Actions
	// runner has no git identity configured, so a commit there fails with
	// "Author identity unknown" unless one is supplied. They are passed per
	// command rather than written to global config, so a run never mutates the
	// machine it happens to be on.
	AuthorName  string
	AuthorEmail string
	// DryRun skips the push. The commit still happens, because it is local to a
	// worktree that is thrown away, and committing is what makes the diff
	// inspectable. Pushing is the first step that changes someone's repository.
	DryRun bool
	// ScratchPaths are worktree-relative paths of transient agent scratch (build
	// and module caches the engine writes inside the worktree). They are removed
	// before staging so they never land in a commit. Defaults to .gocache,
	// .gopath, and .aixgo.
	ScratchPaths []string
}

Git runs git commands in a working directory.

func (*Git) Commit

func (g *Git) Commit(ctx context.Context, dir, message string) (bool, error)

Commit stages all changes except the excluded scratch paths and commits them. It returns committed=false, with no error, when nothing (outside the excluded paths) is staged. Excluding at add time means agent scratch such as a build cache never lands in the commit, and an otherwise no-op run is correctly reported as "nothing to commit" even if scratch files exist.

func (*Git) Push

func (g *Git) Push(ctx context.Context, dir, branch string) error

Push pushes branch from dir to the remote, unless this is a dry run.

func (*Git) Sync

func (g *Git) Sync(ctx context.Context, dir, branch string) error

Sync hard-resets dir to the remote tip of branch. It fetches the branch and resets the working tree to FETCH_HEAD, then removes untracked files. This is used before the fixer runs so it edits the pull request's actual pushed state, never a stale checkout a prior run left behind (a reused worktree). Working on a stale tree and pushing would revert the human's or another commit's changes, which is why this is a deliberate step rather than trusting the worktree.

func (*Git) WorkflowChanges

func (g *Git) WorkflowChanges(ctx context.Context, dir string) ([]string, error)

WorkflowChanges lists the tracked or untracked paths under `.github/workflows/` that the working tree has changed. An empty result means nothing there changed. The paths are returned rather than a bool so an escalation can name the files that caused it, instead of asking the reader to take the agent's word for what it edited.

Jump to

Keyboard shortcuts

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