upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/push.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/git_remote_nostr/push.rs')
-rw-r--r--src/bin/git_remote_nostr/push.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 80aed22..df895b1 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -544,6 +544,65 @@ fn create_rejected_refspecs_and_remotes_refspecs(
544 } 544 }
545 continue; 545 continue;
546 } 546 }
547 // handle annotated tags
548 if let Ok(annotated_tag) = git_repo
549 .git_repo
550 .find_reference(from)
551 .context(format!("cannot find ref {from}"))?
552 .peel(git2::ObjectType::Tag)
553 {
554 if let Some(remote_value) = remote_value {
555 if annotated_tag.id().to_string() == *remote_value {
556 // remote already at correct state
557 } else if is_grasp_server {
558 refspecs_for_remote.push(ensure_force_push_refspec(refspec));
559 } else if refspec.starts_with('+') || refspec.starts_with(':') {
560 refspecs_for_remote.push(refspec.clone());
561 } else {
562 // reject
563 rejected_refspecs
564 .entry(refspec.to_string())
565 .and_modify(|a| a.push(url.to_string()))
566 .or_insert(vec![url.to_string()]);
567 // TODO should we reject or or just warn?
568 term.write_line(
569 format!(
570 "ERROR: {short_name} {to} exists with a different reference. someone else may have pushed new updates. options:\r\n 1. review and integrate remote's tip available via `git checkout {remote_value}` \r\n 2. align remote state with nostr via `ngit sync --ref-name {to} --force` and try to push again",
571 ).as_str(),
572 )?;
573 }
574 } else {
575 // push new tag
576 refspecs_for_remote.push(refspec.clone());
577 }
578 continue;
579 } else if let Some(remote_value) = remote_value {
580 if let Ok(oid) = Oid::from_str(refspec) {
581 if git_repo
582 .git_repo
583 .find_object(oid, Some(git2::ObjectType::Tag))
584 .is_ok()
585 {
586 if is_grasp_server {
587 refspecs_for_remote.push(ensure_force_push_refspec(refspec));
588 } else if refspec.starts_with('+') || refspec.starts_with(':') {
589 refspecs_for_remote.push(refspec.clone());
590 } else {
591 rejected_refspecs
592 .entry(refspec.to_string())
593 .and_modify(|a| a.push(url.to_string()))
594 .or_insert(vec![url.to_string()]);
595 term.write_line(
596 format!(
597 "ERROR: {short_name} {to} exists with a different reference. someone else may have pushed new updates. options:\r\n 1. review and integrate remote's tip available via `git checkout {remote_value}` \r\n 2. align remote state with nostr via `ngit sync --ref-name {to} --force` and try to push again",
598 ).as_str(),
599 )?;
600 }
601 continue;
602 }
603 }
604 }
605
547 let from_tip = git_repo.get_commit_or_tip_of_reference(from)?; 606 let from_tip = git_repo.get_commit_or_tip_of_reference(from)?;
548 if let Some(nostr_value) = nostr_value { 607 if let Some(nostr_value) = nostr_value {
549 if let Some(remote_value) = remote_value { 608 if let Some(remote_value) = remote_value {