Skip to content

Replace git-version with a custom build script#4741

Merged
divergentdave merged 1 commit into
mainfrom
david/git-describe-build-script
Jul 23, 2026
Merged

Replace git-version with a custom build script#4741
divergentdave merged 1 commit into
mainfrom
david/git-describe-build-script

Conversation

@divergentdave

Copy link
Copy Markdown
Collaborator

This replaces our use of git-version with a custom build script. Per m-ou-se/rust-git-version#26, spurious rebuilds can be triggered when the .git/index file is changed, and this seems to explain the rebuilds we've sometimes seen between running cargo test --no-run and cargo test. We can't eliminate this dependency entirely without introducing a build tool other than Cargo, but we can make it conditional. We already use the GIT_REVISION environment variable as a fallback source for the truncated commit hash, for use in container build environments with no git executable or .git directory. The main idea of this PR is to switch the order in which we check these, and omit the dependency on .git/index when the environment variable is in use. Then we can set the environment variable in non-Docker CI builds, and hopefully avoid spurious rebuilds there.

A second benefit of this PR is that it prints a warning message when it uses the fallback "unknown" value. This directed me to add the GIT_REVISION environment variable to our interop test container builds.

@divergentdave
divergentdave requested a review from a team as a code owner July 23, 2026 15:05

@tgeoghegan tgeoghegan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. To make sure I understand: if either git(1) is not installed or .git is not present (e.g., compiling from a source tarball), then the build script falls back to setting GIT_VERSION=unknown, correct?

Comment thread aggregator_api/src/lib.rs Outdated
Comment thread aggregator_api/build.rs Outdated
@divergentdave
divergentdave force-pushed the david/git-describe-build-script branch from 4ed795b to c5440eb Compare July 23, 2026 16:38

@tgeoghegan tgeoghegan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, I use worktrees pretty often so I'm glad this is handled.

@divergentdave
divergentdave enabled auto-merge (squash) July 23, 2026 16:55
@divergentdave
divergentdave merged commit 77903f2 into main Jul 23, 2026
8 checks passed
@divergentdave
divergentdave deleted the david/git-describe-build-script branch July 23, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants