github.com/rotari-dev/rotari/internal/sourcerev

Overview

package sourcerev // import "github.com/rotari-dev/rotari/internal/sourcerev"

Package sourcerev reads the version-control revision of the directory a job
runs from, so a run can record which code it executed. It supports jj and git;
a jj repository colocated with git is read as jj, because git's HEAD there is
the working-copy commit's parent.

Constants

const Timeout = 30 * time.Second
    Timeout bounds each version-control command.

Functions

func Read(dir string) (model.SourceRevision, bool)
    Read returns the revision of the repository containing dir, and false when
    dir is in no jj or git repository. Reading a jj repository snapshots its
    working copy, which records one jj operation, so the commit ID covers the
    files as they are now. A failure to read the revision is reported in the
    result's Error rather than dropped, so the record says the code is unknown.

func ReadAll(dirs []string) model.RunSources
    ReadAll reads the repositories containing dirs, once per repository,
    in the order their first directory appears.