Replace git-version with a custom build script#4741
Merged
Conversation
tgeoghegan
approved these changes
Jul 23, 2026
tgeoghegan
left a comment
Contributor
There was a problem hiding this comment.
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?
divergentdave
force-pushed
the
david/git-describe-build-script
branch
from
July 23, 2026 16:38
4ed795b to
c5440eb
Compare
tgeoghegan
approved these changes
Jul 23, 2026
tgeoghegan
left a comment
Contributor
There was a problem hiding this comment.
Perfect, I use worktrees pretty often so I'm glad this is handled.
divergentdave
enabled auto-merge (squash)
July 23, 2026 16:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces our use of
git-versionwith a custom build script. Per m-ou-se/rust-git-version#26, spurious rebuilds can be triggered when the.git/indexfile is changed, and this seems to explain the rebuilds we've sometimes seen between runningcargo test --no-runandcargo 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 theGIT_REVISIONenvironment 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/indexwhen 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_REVISIONenvironment variable to our interop test container builds.