Skip to content

Commit 4be3614

Browse files
committed
test(cargo-update): --precise not work with tag or short id
This demonstrates the bug described in 13188
1 parent a885354 commit 4be3614

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

tests/testsuite/update.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,3 +1272,70 @@ rustdns.workspace = true
12721272
)
12731273
.run();
12741274
}
1275+
1276+
#[cargo_test]
1277+
fn update_precise_git_revisions() {
1278+
let (git_project, git_repo) = git::new_repo("git", |p| {
1279+
p.file("Cargo.toml", &basic_lib_manifest("git"))
1280+
.file("src/lib.rs", "")
1281+
});
1282+
let tag_name = "Nazgûl";
1283+
git::tag(&git_repo, tag_name);
1284+
1285+
git_project.change_file("src/lib.rs", "fn f() {}");
1286+
git::add(&git_repo);
1287+
let head_id = git::commit(&git_repo).to_string();
1288+
let short_id = &head_id[..8];
1289+
let url = git_project.url();
1290+
1291+
let p = project()
1292+
.file(
1293+
"Cargo.toml",
1294+
&format!(
1295+
r#"
1296+
[package]
1297+
name = "foo"
1298+
version = "0.1.0"
1299+
1300+
[dependencies]
1301+
git = {{ git = '{url}' }}
1302+
"#
1303+
),
1304+
)
1305+
.file("src/lib.rs", "")
1306+
.build();
1307+
1308+
p.cargo("fetch")
1309+
.with_stderr(format!("[UPDATING] git repository `{url}`"))
1310+
.run();
1311+
1312+
assert!(p.read_lockfile().contains(&head_id));
1313+
1314+
p.cargo("update git --precise")
1315+
.arg(tag_name)
1316+
.with_status(101)
1317+
.with_stderr(format!(
1318+
"\
1319+
[ERROR] Unable to update {url}#{tag_name}
1320+
1321+
Caused by:
1322+
precise value for git is not a git revision: {tag_name}
1323+
1324+
Caused by:
1325+
[..]"
1326+
))
1327+
.run();
1328+
1329+
p.cargo("update git --precise")
1330+
.arg(short_id)
1331+
.with_status(101)
1332+
.with_stderr(format!(
1333+
"\
1334+
[UPDATING] git repository `{url}`
1335+
[ERROR] Unable to update {url}#{short_id}
1336+
1337+
Caused by:
1338+
object not found - no match for id ({short_id}00000000000000[..]); [..]",
1339+
))
1340+
.run();
1341+
}

0 commit comments

Comments
 (0)