|
/version reported 4831e5a while HEAD had moved on to 18d18b1: the stamp
is written at build time and build.rs only declared .git/HEAD, which
keeps saying "ref: refs/heads/main" across commits, so a rebuild after a
commit reused the old hash. It now declares the ref file and the index
as well, which is what actually makes a rebuild re-stamp.
Three additions make the stamp trustworthy rather than merely newer:
- `-dirty` when the working tree had uncommitted changes at build time,
so a binary built pre-commit can never claim to be that commit;
- `source_digest`, a hash over the compiled source files, which tells
apart two builds of the same commit -- or of the same dirty tree --
where a commit hash cannot;
- `branch`, so a detached HEAD is visible.
* build.rs: watch .git/HEAD, the ref it points at, and .git/index;
stamp dirty, digest and branch as well as the hash and commit date.
* src/lib.rs (VersionInfo): the three new fields, plus a note saying a
stamp is never advanced by committing without rebuilding.
|
|
* .gitignore: Add __pycache__.
* src/lib.rs (app): Add /version route.
(VersionInfo, version): New struct and handler, returning name,
short_name, version, release, date, and git as a JSON record.
* build.rs: New file. Embeds GN4_GIT_HASH and GN4_COMMIT_DATE via
cargo:rustc-env, read from git rev-parse and git show of HEAD.
* Cargo.toml (dependencies): Add serde with derive feature.
[dev-dependencies]: Add serde_json.
* tests/version.rs: New file.
* test/python/server_test_case.py: New file. ServerTestCase,
wait_for_port, BINARY, HOST, PORT moved here from
test/python/test_hello_world.py.
* test/python/test_hello_world.py: Use server_test_case.ServerTestCase
instead of duplicating setUpClass and tearDownClass.
* test/python/test_version.py: New file.
* guix.scm: Add (gnu packages version-control) to use-modules.
(genenetwork4-git)[native-inputs]: Add git-minimal.
(genenetwork4-git)[arguments]<#:phases>[python-rest-test]: Run
test/python with python3 -m unittest discover instead of invoking
test_hello_world.py directly, so test_version.py also runs.
|