From c9ac3062577e3284c623d8cbe77378eae532b54f Mon Sep 17 00:00:00 2001 From: Vastargazing Date: Tue, 21 Apr 2026 17:48:02 +0300 Subject: [PATCH] test(git): add regression test for full-hash fast path (#13555) --- src/cargo/sources/git/utils.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 402ccc8d093..d09636c0a8d 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -1656,7 +1656,22 @@ fn is_short_hash_of(rev: &str, oid: Oid) -> bool { #[cfg(test)] mod tests { - use super::absolute_submodule_url; + use super::*; + + #[test] + fn github_fast_path_full_hash_returns_needs_fetch() { + let temp_dir = tempfile::TempDir::new().unwrap(); + let mut repo = git2::Repository::init_bare(temp_dir.path()).unwrap(); + let full_hash = "c9040898c9183ddbb9402dcbf749ed06d6ea90ad"; + let reference = GitReference::Rev(full_hash.to_string()); + let gctx = GlobalContext::default().unwrap(); + let expected_oid = rev_to_oid(full_hash).unwrap(); + + let result = + github_fast_path(&mut repo, "https://github.com/user/repo", &reference, &gctx).unwrap(); + + assert!(matches!(result, FastPathRev::NeedsFetch(oid) if oid == expected_oid)); + } #[test] fn test_absolute_submodule_url() {