From b1eabeb315dba8860f34c92e0e362559d3352ef7 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 30 Jul 2025 09:54:15 +0100 Subject: fix(remote): support lightweight tags I have now replicated the issue discussed in the last commit by overwriting my global git config item tag.gpgSign and setting it back to false, which is default the default. ngit was only supporting annotated tags and fiatjaf was pushing a lightweight tag. I'm confident that this will resolve the issue --- src/bin/git_remote_nostr/push.rs | 51 ++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 20 deletions(-) (limited to 'src/bin/git_remote_nostr') diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 9cf6dff..73d76b4 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -790,26 +790,37 @@ fn generate_updated_state( new_state.remove(&format!("{to}{}", "^{}")); } } else if to.contains("refs/tags") { - new_state.insert( - format!("{to}{}", "^{}"), - git_repo - .get_commit_or_tip_of_reference(from) - .context(format!( - "cannot find commit from ref {from} to push to {to}" - ))? - .to_string(), - ); - new_state.insert( - to.to_string(), - git_repo - .git_repo - .find_reference(from) - .context(format!("cannot find ref {from} to push to {to}"))? - .peel(git2::ObjectType::Tag) - .context(format!("cannot find tag id {from} to push to {to}"))? - .id() - .to_string(), - ); + if let Ok(annotated_tag) = git_repo + .git_repo + .find_reference(from) + .context(format!("cannot find ref {from} to push to {to}"))? + .peel(git2::ObjectType::Tag) + { + // this is an anotated tag so there is a tag oid + // ref points to tag oid + new_state.insert(to.to_string(), annotated_tag.id().to_string()); + // dereferenced tags ref points to commit at its head + new_state.insert( + format!("{to}{}", "^{}"), + git_repo + .get_commit_or_tip_of_reference(from) + .context(format!( + "cannot find commit from annotated tag ref {from} to push to {to}" + ))? + .to_string(), + ); + } else { + // this is a lightweight tag so there is no tag oid + new_state.insert( + to.to_string(), + git_repo + .get_commit_or_tip_of_reference(from) + .context(format!( + "cannot find commit from annotated tag ref {from} to push to {to}" + ))? + .to_string(), + ); + } } else { // add or update new_state.insert( -- cgit v1.2.3