Sign in

    PaiGack/moon_shadow/gitinfo does not have a README file

    GitInfo

    pub(all) struct GitInfo {
    available : Bool
    branch : String
    tag : String
    describe : String
    commit : String
    short_commit : String
    commit_date : String
    author : String
    email : String
    dirty : Bool
    ahead : Int
    behind : Int
    } derive(Eq,
    Debug
    )

    A snapshot of the git repository that was checked out when this module was built, rendered into the artifact at build time.

    Filled in by gen, never by the running program: the machine that runs the software has no .git, may not have git, and its cwd is none of your business.

    GitInfo::commit_version

    fn GitInfo::commit_version(self : GitInfo, short? : Bool) -> String

    <commit>[-dirty], or the short form when short is set.

    GitInfo::describe_version

    fn GitInfo::describe_version(self : GitInfo) -> String

    name[-dirty]: the branch name, the tag, or the describe output, whichever is the most specific thing known about HEAD.

    GitInfo::equal

    #deprecated("`GitInfo::equal` is deprecated, use `Eq::equal` instead.")
    fn GitInfo::equal(GitInfo, GitInfo) -> Bool

    GitInfo::is_dirty

    fn GitInfo::is_dirty(self : GitInfo) -> Bool

    Whether the value carries a commit worth printing.

    GitInfo::none

    fn GitInfo::none() -> GitInfo

    The "no git here" value: available = false, everything else empty.

    GitInfo::not_equal

    #deprecated("`GitInfo::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn GitInfo::not_equal(x : GitInfo, y : GitInfo) -> Bool

    GitInfo::to_repr

    #deprecated("`GitInfo::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn GitInfo::to_repr(GitInfo) ->
    Repr

    GitInfo::to_version_string

    fn GitInfo::to_version_string(self : GitInfo) -> String

    available=false becomes unavailable instead of an empty string, so a --version line does not end in dangling separators.

    RepoInfo

    pub(all) struct RepoInfo {
    available : Bool
    locate : RepoLocate
    branch : String
    tag : String
    describe : String
    commit : String
    short_commit : String
    commit_date : String
    author : String
    email : String
    dirty : Bool
    ahead : Int
    behind : Int
    } derive(Eq,
    Debug
    )

    A checkout read straight out of .git, before it is narrowed to a GitInfo.

    Everything here is a file's contents, produced by gen and understood by this package: the generator knows where a ref lives, this side knows what a ref means. locate matters because .git is a file in a worktree and in a submodule, and a reader that walks into one and gives up looks exactly like "no repository here".

    RepoInfo::empty

    fn RepoInfo::empty() -> RepoInfo

    The "nothing here" value.

    RepoInfo::equal

    #deprecated("`RepoInfo::equal` is deprecated, use `Eq::equal` instead.")
    fn RepoInfo::equal(RepoInfo, RepoInfo) -> Bool

    RepoInfo::not_equal

    #deprecated("`RepoInfo::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn RepoInfo::not_equal(x : RepoInfo, y : RepoInfo) -> Bool

    RepoInfo::to_git_info

    fn RepoInfo::to_git_info(self : RepoInfo) -> GitInfo

    The fields of GitInfo a .git reader can answer.

    commit_date / author / email need the commit object, dirty needs the index and a stat per file, and ahead / behind need the commit graph. All four are left empty rather than guessed: gitinfo does not invent a date to fill a hole.

    RepoInfo::to_repr

    #deprecated("`RepoInfo::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn RepoInfo::to_repr(RepoInfo) ->
    Repr

    RepoLocate

    pub(all) enum RepoLocate {
    Ok
    Missing
    Unreadable
    } derive(Eq,
    Debug
    )

    What the reader did with .git.

    RepoLocate::equal

    #deprecated("`RepoLocate::equal` is deprecated, use `Eq::equal` instead.")
    fn RepoLocate::equal(RepoLocate, RepoLocate) -> Bool

    RepoLocate::not_equal

    #deprecated("`RepoLocate::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn RepoLocate::not_equal(x : RepoLocate, y : RepoLocate) -> Bool

    RepoLocate::to_repr

    #deprecated("`RepoLocate::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn RepoLocate::to_repr(RepoLocate) ->
    Repr

    read_repo_info

    fn read_repo_info(cwd : String) -> RepoInfo

    The checkout at cwd, read straight out of the files git would read.

    This is the whole point of the library: the machine that runs the software has no .git and maybe no git, and the build machine should not need a shell either. HEAD, the ref it names, packed-refs, refs/tags/*, the commit object and the index are all plain files — that is what git reads too.

    locate comes back beside the value because it is the one thing worth printing: "no repository" and "a .git that points nowhere" are different mistakes, and GitInfo is baked into the artifact, not logged.