fix(git): peel les tags annotés vers leur commit cible dans log_graph — #218

This commit is contained in:
2026-08-15 20:01:23 +02:00
parent 3d466f9cee
commit bfa4d322e8
2 changed files with 58 additions and 2 deletions

View File

@ -111,3 +111,45 @@ async fn unstage_after_first_commit_resets_index() {
let a = st.iter().find(|s| s.path == "a.txt").unwrap();
assert!(!a.staged, "unstaged change is no longer in the index");
}
#[tokio::test]
async fn git_graph_labels_annotated_tags_on_their_target_commit() {
let tmp = TempDir::new();
let root = tmp.root();
let git = Git2Repository::new();
git.init(&root).await.unwrap();
tmp.write("a.txt", "v1");
git.stage(&root, "a.txt").await.unwrap();
let tagged = git.commit(&root, "tagged commit").await.unwrap();
tmp.write("a.txt", "v2");
git.stage(&root, "a.txt").await.unwrap();
git.commit(&root, "head commit").await.unwrap();
let repo = git2::Repository::open(root.as_str()).unwrap();
let target = repo
.find_object(
git2::Oid::from_str(&tagged.hash).unwrap(),
Some(git2::ObjectType::Commit),
)
.unwrap();
let sig = repo
.signature()
.or_else(|_| git2::Signature::now("IdeA", "idea@localhost"))
.unwrap();
repo.tag("v0.13.0", &target, &sig, "release v0.13.0", false)
.unwrap();
let graph = git.log_graph(&root, 10).await.unwrap();
let commit = graph
.iter()
.find(|commit| commit.hash == tagged.hash)
.expect("tagged ancestor commit is included in graph");
assert!(
commit.refs.iter().any(|r| r == "tag: v0.13.0"),
"annotated tag must be attached to target commit refs, got {:?}",
commit.refs
);
}