Closed
Description
Problem
#13960 unconditionally checks VCS status when doing cargo package
.
However, a VCS (Git specifically) repository could have no commit history, and then it fails cargo package
with such an error:
cargo +beta package --allow-dirty
warning: manifest has no description, license, license-file, documentation, homepage or repository.
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
error: revspec 'HEAD' not found; class=Reference (4); code=NotFound (-3)
Steps
cargo new foo
- cd foo
cargo package --allow-dirty
Possible Solution(s)
The current .cargo_vcs_info.json
format looks like:
{
"git": {
"sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302",
"dirty": true
},
"path_in_vcs": ""
}
If the HEAD
hash cannot be determined, should we instead emit a JSON like
{
"git": {
"dirty": true
},
"path_in_vcs": ""
}
or just don't generate .cargo_vcs_info.json
at all?
Notes
No response
Version
cargo 1.81.0-beta.2 (a2b58c3da 2024-07-16)
release: 1.81.0-beta.2
commit-hash: a2b58c3dad4d554ba01ed6c45c41ff85390560f2
commit-date: 2024-07-16