Skip to content

Commit 4b3f952

Browse files
authored
fix(vendor)!: vendor files with .rej/.orig suffix (#15569)
### What does this PR try to resolve? This is meant to fixes #13191 As git sources and registry sources are considered immutable. I don't think there is any reason excluding those files. There might be a little chance local Git repositories might have those, though that is a rare use case. Alternatively, we could reject all `.rej`/`.orig` files but `Cargo.toml.orig`. ### How should we test and review this PR? Test updates should be sufficient. ### Additional information This is a follow-up of #15514
2 parents ee08992 + 29ecb7f commit 4b3f952

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/cargo/ops/vendor.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,6 @@ fn vendor_this(relative: &Path) -> bool {
618618
// Temporary Cargo files
619619
Some(".cargo-ok") => false,
620620

621-
// Skip patch-style orig/rej files. Published crates on crates.io
622-
// have `Cargo.toml.orig` which we don't want to use here and
623-
// otherwise these are rarely used as part of the build process.
624-
Some(p) if p.ends_with(".orig") || p.ends_with(".rej") => false,
625621
_ => true,
626622
}
627623
}

tests/testsuite/vendor.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,20 +1085,37 @@ fn ignore_files() {
10851085
.build();
10861086

10871087
Package::new("url", "1.4.1")
1088-
.file("src/lib.rs", "")
1088+
// These will be vendored
1089+
.file(".cargo_vcs_info.json", "")
1090+
.file("Cargo.toml.orig", "")
10891091
.file("foo.orig", "")
1090-
.file(".gitignore", "")
1091-
.file(".gitattributes", "")
10921092
.file("foo.rej", "")
1093+
.file("src/lib.rs", "")
1094+
// These will not be vendored
1095+
.file(".cargo-ok", "")
1096+
.file(".gitattributes", "")
1097+
.file(".gitignore", "")
10931098
.publish();
10941099

10951100
p.cargo("vendor --respect-source-config").run();
10961101
let csum = p.read_file("vendor/url/.cargo-checksum.json");
1097-
assert!(!csum.contains("foo.orig"));
1098-
assert!(!csum.contains(".gitignore"));
1099-
assert!(!csum.contains(".gitattributes"));
1100-
assert!(!csum.contains(".cargo-ok"));
1101-
assert!(!csum.contains("foo.rej"));
1102+
assert_e2e().eq(
1103+
csum,
1104+
str![[r#"
1105+
{
1106+
"files": {
1107+
".cargo_vcs_info.json": "[..]",
1108+
"Cargo.toml": "[..]",
1109+
"Cargo.toml.orig": "[..]",
1110+
"foo.orig": "[..]",
1111+
"foo.rej": "[..]",
1112+
"src/lib.rs": "[..]"
1113+
},
1114+
"package": "[..]"
1115+
}
1116+
"#]]
1117+
.is_json(),
1118+
);
11021119
}
11031120

11041121
#[cargo_test]

0 commit comments

Comments
 (0)