cux_buildnumber 0.1.0
cux_buildnumber: ^0.1.0 copied to clipboard
Monotonic build numbers shared through git refs — a Dart port of git-buildnumber.sh v1.3. A library plus a bin/ entrypoint; the only runtime dependency is git on PATH.
Changelog #
0.1.0 #
Same code as 0.1.0-dev.1, promoted after use. The port has allocated build
numbers on two projects since — including a run where allocation failed on
missing credentials after taking a number, and the retry on the same commit
handed the same number back rather than burning the next one. That per-commit
idempotency is the property the whole design rests on, and it had only ever been
exercised deliberately before.
Documents that build numbers are allocation-ordered, not history-ordered: a higher number does not mean a later commit, because allocation happens on demand when somebody builds. Building a parent after its descendant gives the parent the higher number. That is the design working — what is guaranteed is that a number is never reused and never goes backwards as a counter, which is what the stores require — but it reads as a bug to whoever meets it first.
0.1.0-dev.1 #
First publish, and a pre-release twice over. A Dart port of
git-buildnumber.sh v1.3, and a drop-in replacement for it — same refs,
same commands, same stdout.
Published so a second repository can try it, which is the thing it most
needs and the thing its own test suite cannot supply. The acceptance suite is
the shell project's own, so it proves this behaves like the script on the cases
the script's authors thought to write down; it cannot prove the port behaves
like the script in a repository neither of them has seen. Until it has run
somewhere else, treat 0.1.0-dev.1 as an invitation rather than a
recommendation — and keep the shell script available to fall back to, which
costs nothing, since both write the same refs and can be alternated freely.
0.x deliberately. The compatibility surface here is not this package's to
define: it is whatever the shell script does, including the parts nobody would
design on purpose — find-commit printing a whole git log block, get
exiting 0 with empty output on an unnumbered commit. That surface is pinned by a
vendored copy of the shell project's own acceptance suite, which passes, but a
1.0 would be a promise about an interface this package does not own.
What the port is for #
The argument lists handed to git are pure functions returning List<String>,
and the tests read them directly. That is the whole case for rewriting a working
tool: the worst defect in its history was a + on the push refspec beside
--force-with-lease, which git accepts silently and which no run reveals until
two machines allocate at the same instant. It is now a unit test that fails in
milliseconds.
The counter arithmetic and the retry decisions are pure functions for the same reason; sequencing and I/O are confined to one file.
Compatibility #
Chain entries written before v1.3 — which every existing repository has — are read without complaint, the counter blob keeps the trailing newline that is part of its hash, and the two implementations may be used against one repository in either order.
One deliberate divergence: a failed git fetch is fatal in every command.
The shell calls fetch inside && lists, where bash suspends errexit, so a
failure there is silently continued past and fetch can exit 0 having fetched
nothing. Stricter than the original and invisible to the shared suite, so it is
recorded rather than left to be discovered.