diff options
Diffstat (limited to 'src/bin/git_remote_nostr')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 51 |
1 files changed, 31 insertions, 20 deletions
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( | |||
| 790 | new_state.remove(&format!("{to}{}", "^{}")); | 790 | new_state.remove(&format!("{to}{}", "^{}")); |
| 791 | } | 791 | } |
| 792 | } else if to.contains("refs/tags") { | 792 | } else if to.contains("refs/tags") { |
| 793 | new_state.insert( | 793 | if let Ok(annotated_tag) = git_repo |
| 794 | format!("{to}{}", "^{}"), | 794 | .git_repo |
| 795 | git_repo | 795 | .find_reference(from) |
| 796 | .get_commit_or_tip_of_reference(from) | 796 | .context(format!("cannot find ref {from} to push to {to}"))? |
| 797 | .context(format!( | 797 | .peel(git2::ObjectType::Tag) |
| 798 | "cannot find commit from ref {from} to push to {to}" | 798 | { |
| 799 | ))? | 799 | // this is an anotated tag so there is a tag oid |
| 800 | .to_string(), | 800 | // ref points to tag oid |
| 801 | ); | 801 | new_state.insert(to.to_string(), annotated_tag.id().to_string()); |
| 802 | new_state.insert( | 802 | // dereferenced tags ref points to commit at its head |
| 803 | to.to_string(), | 803 | new_state.insert( |
| 804 | git_repo | 804 | format!("{to}{}", "^{}"), |
| 805 | .git_repo | 805 | git_repo |
| 806 | .find_reference(from) | 806 | .get_commit_or_tip_of_reference(from) |
| 807 | .context(format!("cannot find ref {from} to push to {to}"))? | 807 | .context(format!( |
| 808 | .peel(git2::ObjectType::Tag) | 808 | "cannot find commit from annotated tag ref {from} to push to {to}" |
| 809 | .context(format!("cannot find tag id {from} to push to {to}"))? | 809 | ))? |
| 810 | .id() | 810 | .to_string(), |
| 811 | .to_string(), | 811 | ); |
| 812 | ); | 812 | } else { |
| 813 | // this is a lightweight tag so there is no tag oid | ||
| 814 | new_state.insert( | ||
| 815 | to.to_string(), | ||
| 816 | git_repo | ||
| 817 | .get_commit_or_tip_of_reference(from) | ||
| 818 | .context(format!( | ||
| 819 | "cannot find commit from annotated tag ref {from} to push to {to}" | ||
| 820 | ))? | ||
| 821 | .to_string(), | ||
| 822 | ); | ||
| 823 | } | ||
| 813 | } else { | 824 | } else { |
| 814 | // add or update | 825 | // add or update |
| 815 | new_state.insert( | 826 | new_state.insert( |