git

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git creates opt-in commits of an applied change set. It is deliberately minimal and hardened: a commit stages ONLY the caller-supplied paths (never `git add -A`), runs with repository hooks disabled, and executes in a sanitized environment so a git hook, credential helper, or editor can never observe the daemon's privileged environment or provider API keys (§M7).

Index

Constants

This section is empty.

Variables

View Source
var BinPath = "git"

BinPath is the path to the git binary used by Commit. It is a package-level variable so tests can substitute a fake git (mirroring the executor's dockerPath override). Defaults to "git", resolved via PATH.

Functions

func Commit

func Commit(ctx context.Context, workTree string, paths []string, message string) (string, error)

Commit stages the given workspace-relative paths (adds, modifications, and deletions) and creates one commit whose subject is message. It returns the new commit's SHA.

Behavior:

  • If workTree is not a git repository (workTree/.git missing), it returns ("", nil) — a non-repo is a silent no-op, not an error.
  • If there is nothing to commit (the staged diff is empty), it returns ("", nil).
  • Only the given paths are staged; the commit never uses `git add -A`.
  • Repository hooks are disabled (core.hooksPath points at an empty temp dir), so `git commit` cannot execute arbitrary hook code under the daemon's environment.
  • The git process runs with a sanitized environment (PATH/HOME/LANG plus GIT_TERMINAL_PROMPT=0), so inherited GIT_* variables and provider API keys are dropped.

Any real git failure (missing binary, identity not configured, lock held, etc.) is returned as an error; the caller treats it as non-fatal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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