Documentation
¶
Overview ¶
Package git runs the host's git binary for apps deployed from their repository. It knows nothing about CasaOS apps: a folder, a URL, a branch and a way in.
Index ¶
- Constants
- Variables
- func AddWorktree(ctx context.Context, dir, commit, path string, auth Auth) error
- func Attach(ctx context.Context, dir, branch string) error
- func Clone(ctx context.Context, url, branch, dir string, auth Auth) error
- func DefaultBranch(ctx context.Context, url string, auth Auth) (string, error)
- func Detach(ctx context.Context, dir string) error
- func DropKeptCommit(ctx context.Context, dir, commit string) error
- func FastForward(ctx context.Context, dir, commit string) error
- func Fetch(ctx context.Context, dir, url, branch string, auth Auth) (string, error)
- func FetchCommit(ctx context.Context, dir, url, commit string, auth Auth) error
- func FetchTag(ctx context.Context, dir, url, tag string, auth Auth) (string, error)
- func HasCommit(ctx context.Context, dir, commit string) bool
- func IsAncestor(ctx context.Context, dir, ancestor, descendant string) (bool, error)
- func IsTracked(ctx context.Context, dir, path string) (bool, error)
- func KeepCommit(ctx context.Context, dir, commit string) error
- func KeptCommits(ctx context.Context, dir string) ([]string, error)
- func LsRemote(ctx context.Context, url, branch string, auth Auth) (string, error)
- func LsRemoteTags(ctx context.Context, url string, auth Auth) (map[string]string, error)
- func Prune(ctx context.Context, dir string) error
- func RemoveWorktree(ctx context.Context, dir, path string) error
- func ResetKeep(ctx context.Context, dir, commit string) error
- func Subject(ctx context.Context, dir, commit string) (string, error)
- func ValidRefName(name string) bool
- type Auth
- type Error
- type Info
Constants ¶
const ( AccessNone = "none" AccessKey = "key" AccessToken = "token" )
How a remote is reached.
Variables ¶
var ErrNoSSHClient = errors.New("the ssh client is not installed on this machine")
ErrNoSSHClient is the answer for a deploy key on a machine that cannot use one.
Functions ¶
func AddWorktree ¶
AddWorktree checks commit out, detached, at path, submodules included.
func Attach ¶ added in v0.4.62
Attach puts the work tree at dir on branch, made or moved to the commit it is on: no file moves.
func DefaultBranch ¶
DefaultBranch is the branch the remote's HEAD points to.
func Detach ¶ added in v0.4.62
Detach leaves the work tree at dir in detached HEAD on the commit it is on: no file and no branch moves.
func DropKeptCommit ¶ added in v0.4.62
DropKeptCommit removes the ref KeepCommit made for commit.
func FastForward ¶
FastForward moves the checked-out branch forward to commit, and refuses anything else.
func FetchCommit ¶ added in v0.4.62
FetchCommit fetches commit itself from url into dir. Not every forge serves a commit by its hash: one that does not refuses it.
func FetchTag ¶ added in v0.4.62
FetchTag fetches the tag from url into dir and returns the commit it names, an annotated tag peeled. No local ref is written.
func IsAncestor ¶
IsAncestor reports whether ancestor is descendant or one of its ancestors.
func KeepCommit ¶ added in v0.4.62
KeepCommit makes dir keep commit, whatever becomes of the refs that brought it.
func KeptCommits ¶ added in v0.4.62
KeptCommits is every commit dir keeps a ref for.
func LsRemoteTags ¶ added in v0.4.62
LsRemoteTags is every tag of the remote and the commit it names. An annotated tag comes twice: its plain line names the tag object, its peeled line `<name>^{}` the commit, which wins. A name that is no valid ref name is left out, so that it never reaches git. So is a line whose hash is no commit hash: a ref name with a newline in it, which a hostile remote can advertise, makes ls-remote print a line of its own that starts with anything.
func RemoveWorktree ¶
RemoveWorktree removes a worktree AddWorktree made, and what git knows of it.
func ResetKeep ¶
ResetKeep moves the checked-out branch, or a detached HEAD, to commit, keeping local changes git can keep. A rollback, a revert, a redeployment, a first deployment and every move of an app that follows tags use it: tags do not form a line.
func ValidRefName ¶ added in v0.4.62
ValidRefName is a name git reads as a branch or a tag name: not an option, not a revision expression (`..`, `@`, `@{`, `~`, `^`), and no character a ref name forbids. Empty passes: a caller that needs a name checks that itself.
Types ¶
type Auth ¶
type Auth struct {
Mode string
KeyPath string
KnownHostsPath string
Token string
// AskpassDir is where a token's askpass helper is written, in a folder of its own that
// goes after each command. Not /tmp, which may be mounted noexec.
AskpassDir string
}
Auth is how a remote is reached. It becomes environment, never arguments.