upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/lib/git_events.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-10-17 09:30:35 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-10-17 10:20:43 +0100
commit2bf98e91e5b5a7d1b18557e65711b5ef3d1a54a3 (patch)
tree0a7726ee5a6344bae6dea0f8c784548bb75b622f /src/lib/git_events.rs
parent0e8fcc743b343c620a6723f5ad517ab98f140401 (diff)
feat(send): add `merge-base` tag to PR (Update)
following its inclusion in the NIP-34 spec
Diffstat (limited to 'src/lib/git_events.rs')
-rw-r--r--src/lib/git_events.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs
index 56ebcef..e907a9b 100644
--- a/src/lib/git_events.rs
+++ b/src/lib/git_events.rs
@@ -385,7 +385,9 @@ pub fn generate_unsigned_pr_or_update_event(
385 signing_public_key: &PublicKey, 385 signing_public_key: &PublicKey,
386 root_proposal: Option<&Event>, 386 root_proposal: Option<&Event>,
387 title_description_overide: &Option<(String, String)>, 387 title_description_overide: &Option<(String, String)>,
388 commit: &Sha1Hash, 388 tip: &Sha1Hash,
389 first_commit: &Sha1Hash,
390 merge_base: Option<&Sha1Hash>,
389 clone_url_hint: &[&str], 391 clone_url_hint: &[&str],
390 mentions: &[nostr::Tag], 392 mentions: &[nostr::Tag],
391) -> Result<UnsignedEvent> { 393) -> Result<UnsignedEvent> {
@@ -404,7 +406,7 @@ pub fn generate_unsigned_pr_or_update_event(
404 } else if let Some(cl) = &root_patch_cover_letter { 406 } else if let Some(cl) = &root_patch_cover_letter {
405 cl.title.clone() 407 cl.title.clone()
406 } else { 408 } else {
407 git_repo.get_commit_message_summary(commit)? 409 git_repo.get_commit_message_summary(first_commit)?
408 }; 410 };
409 411
410 let description = if let Some((_, description)) = &title_description_overide { 412 let description = if let Some((_, description)) = &title_description_overide {
@@ -412,7 +414,10 @@ pub fn generate_unsigned_pr_or_update_event(
412 } else if let Some(cl) = &root_patch_cover_letter { 414 } else if let Some(cl) = &root_patch_cover_letter {
413 cl.description.clone() 415 cl.description.clone()
414 } else { 416 } else {
415 let mut description = git_repo.get_commit_message(commit)?.trim().to_string(); 417 let mut description = git_repo
418 .get_commit_message(first_commit)?
419 .trim()
420 .to_string();
416 if let Some(remaining_description) = description.strip_prefix(&title) { 421 if let Some(remaining_description) = description.strip_prefix(&title) {
417 description = remaining_description.trim().to_string(); 422 description = remaining_description.trim().to_string();
418 } 423 }
@@ -471,6 +476,15 @@ pub fn generate_unsigned_pr_or_update_event(
471 .concat() 476 .concat()
472 }; 477 };
473 478
479 let merge_base_tag = if let Some(merge_base) = merge_base {
480 vec![Tag::custom(
481 nostr::TagKind::Custom(std::borrow::Cow::Borrowed("merge-base")),
482 vec![format!("{merge_base}")],
483 )]
484 } else {
485 vec![]
486 };
487
474 Ok( 488 Ok(
475 if root_proposal.is_some() && root_patch_cover_letter.is_none() { 489 if root_proposal.is_some() && root_patch_cover_letter.is_none() {
476 EventBuilder::new(KIND_PULL_REQUEST_UPDATE, "") 490 EventBuilder::new(KIND_PULL_REQUEST_UPDATE, "")
@@ -508,7 +522,7 @@ pub fn generate_unsigned_pr_or_update_event(
508 Tag::from_standardized(TagStandard::Reference(format!("{root_commit}"))), 522 Tag::from_standardized(TagStandard::Reference(format!("{root_commit}"))),
509 Tag::custom( 523 Tag::custom(
510 nostr::TagKind::Custom(std::borrow::Cow::Borrowed("c")), 524 nostr::TagKind::Custom(std::borrow::Cow::Borrowed("c")),
511 vec![format!("{commit}")], 525 vec![format!("{tip}")],
512 ), 526 ),
513 Tag::custom( 527 Tag::custom(
514 nostr::TagKind::Custom(std::borrow::Cow::Borrowed("clone")), 528 nostr::TagKind::Custom(std::borrow::Cow::Borrowed("clone")),
@@ -518,6 +532,7 @@ pub fn generate_unsigned_pr_or_update_event(
518 .collect::<Vec<String>>(), 532 .collect::<Vec<String>>(),
519 ), 533 ),
520 ], 534 ],
535 merge_base_tag,
521 repo_ref 536 repo_ref
522 .maintainers 537 .maintainers
523 .iter() 538 .iter()