import "github.com/egdaemon/eg/runtime/wasi/eggit"

Package eggit provides functionality around git and assumes that the git command is available.

func Archive

func Archive(dir, dest string) eg.OpFn

Archive creates a gzipped tar archive of the git repository at dir, writing it to dest. The archive is created from the commit specified by the eg environment.

func AutoArchive

func AutoArchive(ctx context.Context, op eg.Op) error

AutoArchive clones the repository from the eg environment and archives it.

func AutoClone

func AutoClone(ctx context.Context, _ eg.Op) error

clone the repository specified by the eg environment variables into the working directory.

func Clone

func Clone(ctx context.Context, uri, remote, commit string) error

clone a git repository from the given uri, remote and treeish.

func Commit

func Commit(c Changer, options ...commitopts) eg.OpFn

Commit returns an op that commits the changes of the change's worktree to a new branch. does nothing when there are no changes. commits are authored by the head commit's author, falling back to egdaemon <noreply@egdaemon.com>.

func Commitish

func Commitish(ctx context.Context, treeish string) string

determine the commit hash for the given name.

func EnvCanonicalURI

func EnvCanonicalURI() string

func Pattern

func Pattern(s string) string

substitute values in the provided pattern using the environment variable commit. see commit.StringReplace for more details.

func PatternClean

func PatternClean(pattern string) string

completely clean any git substitutions from the pattern.

func Pristine

func Pristine() eg.OpFn

ensures the workspace has not been modified. useful for detecting if there have been changes during the run.

func Push

func Push(c Changer, options ...pushopts) eg.OpFn

Push returns an op that pushes the branch committed by Commit to the remote. does nothing when nothing was committed. when cloning is disabled (EG_UNSAFE_GIT_CLONE_ENABLED=false), e.g.) eg compute local, there is nothing to push to, so the commits are written as a patch to the workspace directory instead, see egenv.WorkspaceDirectory. the patch is named {md5(branch)}.patch, md5 formatted as a uuid, within the .eg/.patches directory. the patch includes the commit message and author, apply it with git am. the token used to push is read the same way as ffigit.Bearer and is only provided to git through the environment.

func StringReplace

func StringReplace(pattern string) string

substitute values in the provided pattern using the environment variable commit.

Deprecated: use Pattern.

type Changer

Changer provides access to a change's worktree.

type Changer interface {
    // Path is the directory of the worktree, joined with the given relative paths.
    Path(rel ...string) string
    // Runtime is a shell command running within the worktree.
    Runtime() shell.Command
}
⬤