From 3a510941d8e58c79744c27b67004e04740b48898 Mon Sep 17 00:00:00 2001 From: Vedant Madane <6527493+VedantMadane@users.noreply.github.com> Date: Tue, 25 Aug 2026 07:55:37 +0530 Subject: [PATCH] fix: Honor updateRef when creating signed commits - After commit_signed, update the named ref (create or set_target) - Matches unsigned commit() behavior so signed commits are not unreachable Fixes #218 Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com> --- src/commit.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/commit.rs b/src/commit.rs index 184d9df..87dadb8 100644 --- a/src/commit.rs +++ b/src/commit.rs @@ -444,9 +444,23 @@ impl Repository { let commit_content_str = std::str::from_utf8(&commit_content)?.to_string(); - self + let oid = self .inner - .commit_signed(&commit_content_str, &signature_str, signature_field.as_deref())? + .commit_signed(&commit_content_str, &signature_str, signature_field.as_deref())?; + + // commit_signed only writes the object; honor update_ref like the unsigned path. + if let Some(name) = update_ref.as_deref() { + match self.inner.find_reference(name) { + Ok(mut reference) => { + reference.set_target(oid, "commit (signed)")?; + } + Err(_) => { + self.inner.reference(name, oid, true, "commit (signed)")?; + } + } + } + + oid } else { self.inner.commit( update_ref.as_deref(),