You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #13832 - ferrocene:pa-source-tarball-git, r=weihanglo
Populate git information when building Cargo from Rust's source tarball
### What does this PR try to resolve?
Right now Cargo doesn't populate the commit hash or date in its version output when it's built from Rust's plain source tarball (like `rustc-1.77.2-src.tar.xz`). That's because Cargo's build script only looks for information in the `.git` directory, which is missing from that tarball.
I opened rust-lang/rust#124553 to have bootstrap inject a `git-commit-info` file in `src/tools/cargo` when building the plain source tarball, containing the correct git information. This is the approach also used by the compiler.
This PR updates the build script to read the information from that file if there is no `.git` and the file is present.
### How should we test and review this PR?
To test the PR you need to move the `.git` directory somewhere else and create a `git-commit-info` file like this:
```
25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
25ef9e3d8
2024-04-09
```
Then clearing the build cache and running `cargo run -- -vV` should show the git information in the `git-commit-info` file.
### Additional information
This PR can be merged independently from rust-lang/rust#124553
0 commit comments