git

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package git owns git CLI interaction for initech project bootstrap. It handles repo initialization, submodule management, and commits.

All operations take an exec.Runner, making the package fully testable without a real git installation. This package does not know about config or scaffold.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSubmodule

func AddSubmodule(runner iexec.Runner, repoDir, url, subPath string) error

AddSubmodule adds a git submodule at the specified path within the repo. The path is relative to the repo root (e.g., "eng1/src"). The URL is normalized before use (bare hostnames get git@ SSH prefix).

func CleanFailedSubmodule added in v1.10.3

func CleanFailedSubmodule(runner iexec.Runner, repoDir, subPath string)

CleanFailedSubmodule removes leftover artifacts from a failed git submodule add. This prevents cascading failures: a stale index.lock blocks all subsequent git operations, and partial checkout directories cause "does not have a commit checked out" errors during git add.

Cleanup is best-effort; errors are silently ignored because the artifacts may not all exist depending on where the submodule add failed.

func CommitAll

func CommitAll(runner iexec.Runner, dir, message string) error

CommitAll stages all files and creates a commit with the given message. Returns an error if staging or commit fails.

func Init

func Init(runner iexec.Runner, dir string) error

Init runs git init in the given directory. If the directory already contains a .git directory, it's a no-op and returns nil.

func IsEmptyRepoError added in v1.10.3

func IsEmptyRepoError(err error) bool

IsEmptyRepoError reports whether the error indicates the remote repository has no commits. This happens when git submodule add clones a freshly created repo (e.g., a new GitHub repo with no initial commit). Git fails with "You are on a branch yet to be born" because there is no HEAD to check out.

func NormalizeRepoURL added in v1.5.8

func NormalizeRepoURL(url string) string

NormalizeRepoURL converts bare repository references like "github.com/user/repo" into proper git URLs. If the URL already has a recognized protocol prefix (https://, http://, git@, ssh://), it is returned unchanged. Otherwise, the first "/" after the host is converted to ":" and "git@" is prepended, producing SSH URLs like "git@github.com:user/repo.git".

Types

This section is empty.

Jump to

Keyboard shortcuts

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