upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/git_remote_nostr/push.rs26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index b0e7726..bd1188b 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -1524,7 +1524,7 @@ fn update_remote_refs_pushed(
1524 refspec: &str, 1524 refspec: &str,
1525 nostr_remote_url: &str, 1525 nostr_remote_url: &str,
1526) -> Result<()> { 1526) -> Result<()> {
1527 let (from, _) = refspec_to_from_to(refspec)?; 1527 let (from, to) = refspec_to_from_to(refspec)?;
1528 1528
1529 let target_ref_name = refspec_remote_ref_name(git_repo, refspec, nostr_remote_url)?; 1529 let target_ref_name = refspec_remote_ref_name(git_repo, refspec, nostr_remote_url)?;
1530 1530
@@ -1533,14 +1533,30 @@ fn update_remote_refs_pushed(
1533 remote_ref.delete()?; 1533 remote_ref.delete()?;
1534 } 1534 }
1535 } else { 1535 } else {
1536 let commit = reference_to_commit(git_repo, from) 1536 // For annotated tags, store the tag object OID (not the peeled commit)
1537 .context(format!("failed to get commit of reference {from}"))?; 1537 // to match what generate_updated_state puts in the nostr state event.
1538 // For branches and lightweight tags, store the commit OID as before.
1539 let oid = if to.starts_with("refs/tags/") {
1540 if let Ok(tag_obj) = git_repo
1541 .find_reference(from)
1542 .context(format!("failed to find reference: {from}"))?
1543 .peel(git2::ObjectType::Tag)
1544 {
1545 tag_obj.id()
1546 } else {
1547 reference_to_commit(git_repo, from)
1548 .context(format!("failed to get commit of reference {from}"))?
1549 }
1550 } else {
1551 reference_to_commit(git_repo, from)
1552 .context(format!("failed to get commit of reference {from}"))?
1553 };
1538 if let Ok(mut remote_ref) = git_repo.find_reference(&target_ref_name) { 1554 if let Ok(mut remote_ref) = git_repo.find_reference(&target_ref_name) {
1539 remote_ref.set_target(commit, "updated by nostr remote helper")?; 1555 remote_ref.set_target(oid, "updated by nostr remote helper")?;
1540 } else { 1556 } else {
1541 git_repo.reference( 1557 git_repo.reference(
1542 &target_ref_name, 1558 &target_ref_name,
1543 commit, 1559 oid,
1544 false, 1560 false,
1545 "created by nostr remote helper", 1561 "created by nostr remote helper",
1546 )?; 1562 )?;