Skip to content

Commit deb96bc

Browse files
committed
ensure repo is a proper url
rust-lang/rust#142682 had some crater runs fail as crater didn't reject the invalid git repo url early
1 parent 15e97af commit deb96bc

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ tera = "1.19.1"
6868
thiserror = "1.0.38"
6969
tokio = "1.24"
7070
toml = "0.8.6"
71-
url = "2"
71+
url = { version = "2", features = ["serde"] }
7272
walkdir = "2"
7373
warp = "0.3"
7474
zstd = "0.13.0"

src/runner/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub(super) fn run_test(
248248
let mut build = build_dir.build(ctx.toolchain, krate, sandbox);
249249

250250
for patch in ctx.toolchain.patches.iter() {
251-
build = build.patch_with_git(&patch.name, &patch.repo, &patch.branch);
251+
build = build.patch_with_git(&patch.name, &patch.repo.as_str(), &patch.branch);
252252
}
253253

254254
detect_broken(build.run(|build| {

src/toolchain.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ pub enum ToolchainParseError {
105105
InvalidFlag(String),
106106
#[error("invalid toolchain SHA: {0} is missing a `try#` or `master#` prefix")]
107107
PrefixMissing(String),
108+
#[error("invalid url {0:?}: {1}")]
109+
InvalidUrl(String, url::ParseError),
108110
}
109111

110112
lazy_static! {
@@ -187,7 +189,9 @@ impl FromStr for Toolchain {
187189
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Clone)]
188190
pub struct CratePatch {
189191
pub name: String,
190-
pub repo: String,
192+
// cargo currently doesn't accept scp-style "URLs" rust-lang/crates#1851
193+
// so ensure its a proper URL
194+
pub repo: url::Url,
191195
pub branch: String,
192196
}
193197

@@ -202,7 +206,8 @@ impl FromStr for CratePatch {
202206
} else {
203207
Ok(CratePatch {
204208
name: params[0].into(),
205-
repo: params[1].into(),
209+
repo: url::Url::parse(params[1])
210+
.map_err(|err| ToolchainParseError::InvalidUrl(params[1].into(), err))?,
206211
branch: params[2].into(),
207212
})
208213
}
@@ -291,7 +296,7 @@ mod tests {
291296
ci_try: $ci_try,
292297
patches: vec![CratePatch {
293298
name: "example".to_string(),
294-
repo: "https://git.example.com/some/repo".to_string(),
299+
repo: url::Url::parse("https://git.example.com/some/repo").unwrap(),
295300
branch: "master".to_string()
296301
}]
297302
});
@@ -306,7 +311,7 @@ mod tests {
306311
ci_try: $ci_try,
307312
patches: vec![CratePatch {
308313
name: "example".to_string(),
309-
repo: "https://git.example.com/some/repo".to_string(),
314+
repo: url::Url::parse("https://git.example.com/some/repo").unwrap(),
310315
branch: "master".to_string()
311316
}]
312317
});

0 commit comments

Comments
 (0)