Skip to content

Commit b662ada

Browse files
committed
use find_matching_rev
1 parent 713678c commit b662ada

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

src/utils/vcs.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,6 @@ fn test_partial_sha_resolution_with_real_git() {
13371337
.trim()
13381338
.to_owned();
13391339

1340-
// Test that partial SHA is treated as symbolic reference
13411340
let spec = CommitSpec {
13421341
repo: "test-repo".to_owned(),
13431342
path: Some(dir.path().to_path_buf()),
@@ -1348,23 +1347,33 @@ fn test_partial_sha_resolution_with_real_git() {
13481347
match spec.reference() {
13491348
GitReference::Symbolic(s) => {
13501349
assert_eq!(s, short_sha);
1351-
1352-
// Now test that it resolves to the correct full SHA
1353-
let repo = git2::Repository::open(dir.path()).expect("Failed to open git repo");
1354-
let resolved = repo
1355-
.revparse_single(&short_sha)
1356-
.expect("Failed to resolve short SHA");
1357-
let resolved_sha = resolved.id().to_string();
1358-
1359-
assert_eq!(
1360-
resolved_sha, full_sha,
1361-
"Partial SHA {short_sha} should resolve to full SHA {full_sha}, but got {resolved_sha}"
1362-
);
13631350
}
13641351
GitReference::Commit(_) => {
13651352
panic!("Partial SHA should be treated as symbolic reference")
13661353
}
13671354
}
1355+
1356+
let reference = spec.reference();
1357+
let repos = [Repo {
1358+
id: String::from("1"),
1359+
name: String::from("test-repo"),
1360+
url: Some(String::from("https://github.com/test/test-repo")),
1361+
provider: RepoProvider {
1362+
id: String::from("integrations:github"),
1363+
name: String::from("GitHub"),
1364+
},
1365+
status: String::from("active"),
1366+
date_created: chrono::Utc::now(),
1367+
}];
1368+
1369+
let resolved_sha = find_matching_rev(reference, &spec, &repos, false, None)
1370+
.expect("Failed to resolve partial SHA")
1371+
.expect("Partial SHA should resolve to a commit");
1372+
1373+
assert_eq!(
1374+
resolved_sha, full_sha,
1375+
"Partial SHA {short_sha} should resolve to full SHA {full_sha}, but got {resolved_sha}"
1376+
);
13681377
}
13691378

13701379
#[cfg(test)]

0 commit comments

Comments
 (0)