upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-03-09 09:14:03 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-03-09 10:02:25 +0000
commit3daf61e74c8969c91333bc92c4914c8c6077592c (patch)
tree896da35d6e47ca71b8b9d9ca6153ad374f8ee710 /src/bin/git_remote_nostr
parent45b0f8c6b1dab2d51338d88b2a7caf4b1b571f4d (diff)
fix(push): gracefully handle errors identifying potential PR merges
Errors from get_merged_status_events no longer abort the push; the call site now uses if let Ok(...) so failures are silently skipped. Also replace an .unwrap() in create_merge_events with a safe .map().unwrap_or_default() to avoid any panic in that path.
Diffstat (limited to 'src/bin/git_remote_nostr')
-rw-r--r--src/bin/git_remote_nostr/push.rs39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 3b5e05d..1f4b3ef 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -357,7 +357,7 @@ async fn create_and_publish_events_and_proposals(
357 events.push(new_repo_state.event); 357 events.push(new_repo_state.event);
358 } 358 }
359 359
360 for event in get_merged_status_events( 360 if let Ok(merged_status_events) = get_merged_status_events(
361 term, 361 term,
362 &repo_ref.to_nostr_git_url(&None), 362 &repo_ref.to_nostr_git_url(&None),
363 repo_ref, 363 repo_ref,
@@ -365,9 +365,11 @@ async fn create_and_publish_events_and_proposals(
365 &signer, 365 &signer,
366 git_server_refspecs, 366 git_server_refspecs,
367 ) 367 )
368 .await? 368 .await
369 { 369 {
370 events.push(event); 370 for event in merged_status_events {
371 events.push(event);
372 }
371 } 373 }
372 374
373 if let Ok(Some(repo_ref_event)) = get_maintainers_yaml_update( 375 if let Ok(Some(repo_ref_event)) = get_maintainers_yaml_update(
@@ -1294,7 +1296,14 @@ async fn create_merge_events(
1294 term.write_line( 1296 term.write_line(
1295 format!( 1297 format!(
1296 "merge commit {}: create nostr proposal status event", 1298 "merge commit {}: create nostr proposal status event",
1297 &merged_patches.keys().next().unwrap().to_string()[..7], 1299 merged_patches
1300 .keys()
1301 .next()
1302 .map(|h| {
1303 let s = h.to_string();
1304 s[..s.len().min(7)].to_string()
1305 })
1306 .unwrap_or_default(),
1298 ) 1307 )
1299 .as_str(), 1308 .as_str(),
1300 )?; 1309 )?;
@@ -1527,14 +1536,19 @@ async fn get_proposal_and_revision_root_from_patch_or_pr_or_pr_update(
1527 .clone(), 1536 .clone(),
1528 )?; 1537 )?;
1529 1538
1530 get_events_from_local_cache( 1539 let cached = get_events_from_local_cache(
1531 git_repo.get_path()?, 1540 git_repo.get_path()?,
1532 vec![nostr::Filter::default().id(proposal_or_revision_id)], 1541 vec![nostr::Filter::default().id(proposal_or_revision_id)],
1533 ) 1542 )
1534 .await? 1543 .await?;
1535 .first() 1544 cached
1536 .unwrap() 1545 .first()
1537 .clone() 1546 .ok_or_else(|| {
1547 anyhow::anyhow!(
1548 "proposal or revision root event {proposal_or_revision_id} not found in local cache",
1549 )
1550 })?
1551 .clone()
1538 }; 1552 };
1539 1553
1540 if !proposal_or_revision.kind.eq(&Kind::GitPatch) { 1554 if !proposal_or_revision.kind.eq(&Kind::GitPatch) {
@@ -1551,7 +1565,12 @@ async fn get_proposal_and_revision_root_from_patch_or_pr_or_pr_update(
1551 .tags 1565 .tags
1552 .iter() 1566 .iter()
1553 .find(|t| t.is_reply()) 1567 .find(|t| t.is_reply())
1554 .unwrap() 1568 .ok_or_else(|| {
1569 anyhow::anyhow!(
1570 "revision-root patch event {} missing reply tag",
1571 proposal_or_revision.id
1572 )
1573 })?
1555 .as_slice()[1], 1574 .as_slice()[1],
1556 )?, 1575 )?,
1557 Some(proposal_or_revision.id), 1576 Some(proposal_or_revision.id),