# `Macaw.Host.Build`
[🔗](https://github.com/dcoai/macaw_host/blob/v0.1.4/lib/macaw/host/build.ex#L1)

An app's build: its version and the commit it was built from, fixed at
compile time.

    defmodule MyApp.Build do
      use Macaw.Host.Build, otp_app: :my_app
    end

    MyApp.Build.sha()      # "3f639e84a704"
    MyApp.Build.version()  # "1.2.0"

The SHA is `BUILD_SHA` when the image build sets it, else the app's own
git checkout's, else `"unknown"`. It is a macro so it runs while the
*app* compiles, in the app's directory: as a function in this library it
would read this library's checkout, or nothing.

When the SHA comes from the checkout, the module declares the checkout's
`HEAD` file and the ref it names (the branch's file, or `packed-refs`
when the branch is only packed), and HEAD's reflog, as
`@external_resource`s, so a new
commit or a switched branch recompiles it rather than leaving the old
SHA in an incremental build. They are read as files, never by running
git, and only those that exist are declared. The checkout is the first
`.git` found from the app's directory upward (an umbrella's is at its
root; a worktree's `.git` file is followed), or `git_dir:` when given.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
