git

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const NilHash = Hash("")

NilHash is the zero value, i.e. the absence of a Hash.

Variables

View Source
var (
	// ErrRepoExists means that the given directory already has a git repository
	// in it, and a new repository can't be created there.
	ErrRepoExists = errors.New("Repo already exists")
)

Functions

This section is empty.

Types

type Git

type Git interface {
	NewRepository(dst string) (WriteableRepository, error)
	OpenRepository(repoDir string) (Repository, error)
	GetRelativeLocation(currentDir string) (string, error)
}

Git is an interface to a subset of Git functionality.

func NewGit

func NewGit() Git

NewGit returns a new git interface.

type Hash

type Hash string

Hash is a git SHA-1, base16 encoded

type Repository

type Repository interface {
	RootDir() string
	ResolveCommit(ref string) (ResolvedUserRef, error)
	RecursiveSharedCloneTo(dst string) (WorktreeRepository, error)
}

Repository represents a git repository somewhere on disk. It's not able to perform destructive actions -- for that, you need to obtain a WriteableRepository or a WorkingRepository.

type ResolvedCommit

type ResolvedCommit interface {
	Repo() Repository
	Hash() Hash
}

ResolvedCommit represents a commit which definitely exists within its associated repository.

type ResolvedUserRef

type ResolvedUserRef interface {
	Commit() ResolvedCommit
	UserRef() string
}

ResolvedUserRef represents a user-provided commit-ish, which has then been resolved to a commit in the git repo. This is useful info together for referring back to input that the user has supplied; notably, the String() method returns a representation of the user's input and the SHA together.

type WorktreeRepository

type WorktreeRepository interface {
	Repository
	Remove() error
	Checkout(commit ResolvedCommit) error
}

WorktreeRepository represents a temporary scratch git repository where it's ok to checkout files, and delete the repository later, but not to commit things.

type WriteableRepository

type WriteableRepository interface {
	// WriteableRepository is intentionally not a superset of WorktreeRepository
	// so we don't have to be aware of Checkouts etc in the Commit / Clear
	// methods.
	Repository
	CommitEverythingInWorktree(message string) (Hash, error)
	ClearSourceControlledFilesFromWorktree() error
}

WriteableRepository is a Repository that allows commits / edits to the git history.

Jump to

Keyboard shortcuts

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