Skip to content

Commit 2165205

Browse files
committed
Added readme, license, license-file, keywords, and categories to fingerprint metadata
1 parent 652623b commit 2165205

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,18 @@ fn calculate_normal(
15311531
));
15321532
// Include metadata since it is exposed as environment variables.
15331533
let m = unit.pkg.manifest().metadata();
1534-
let metadata = util::hash_u64((&m.authors, &m.description, &m.homepage, &m.repository));
1534+
let metadata = util::hash_u64((
1535+
&m.authors,
1536+
&m.description,
1537+
&m.homepage,
1538+
&m.repository,
1539+
&m.readme,
1540+
&m.license,
1541+
&m.license_file,
1542+
&m.documentation,
1543+
&m.categories,
1544+
&m.keywords,
1545+
));
15351546
let mut config = StableHasher::new();
15361547
if let Some(linker) = build_runner.compilation.target_linker(unit.kind) {
15371548
linker.hash(&mut config);

tests/testsuite/freshness_checksum.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,11 +2018,33 @@ fn metadata_change_invalidates() {
20182018
"description = \"desc\"",
20192019
"homepage = \"https://example.com\"",
20202020
"repository =\"https://example.com\"",
2021+
"readme =\"README.md\"",
2022+
"license =\"MIT\"",
2023+
"license-file =\"foo.txt\"",
2024+
"categories = [\"foo\"]",
2025+
"keywords = [\"foo\"]",
2026+
"documentation =\"https://example.com\"",
20212027
] {
2028+
let cargo_toml = p.root().join("Cargo.toml");
2029+
2030+
// license and license-file together will emit a warning, so remove license since we
2031+
// already tested it. Also rebuild it so that when we add license-file, we validate the
2032+
// fingerprint was updated.
2033+
if attr.starts_with("license-file") {
2034+
let contents = fs::read_to_string(&cargo_toml)
2035+
.unwrap()
2036+
.replace("license =\"MIT\"\n", "");
2037+
fs::write(&cargo_toml, &contents).unwrap();
2038+
2039+
p.cargo("build -Zchecksum-freshness")
2040+
.masquerade_as_nightly_cargo(&["checksum-freshness"])
2041+
.run();
2042+
}
2043+
20222044
let mut file = OpenOptions::new()
20232045
.write(true)
20242046
.append(true)
2025-
.open(p.root().join("Cargo.toml"))
2047+
.open(cargo_toml)
20262048
.unwrap();
20272049
writeln!(file, "{}", attr).unwrap();
20282050
p.cargo("build -Zchecksum-freshness")

0 commit comments

Comments
 (0)