diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 6 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/send.rs | 6 | ||||
| -rw-r--r-- | src/lib/git/mod.rs | 1 | ||||
| -rw-r--r-- | src/lib/git_events.rs | 23 | ||||
| -rw-r--r-- | src/lib/push.rs | 8 |
5 files changed, 38 insertions, 6 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 8c102ee..8a750ce 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -460,11 +460,15 @@ async fn generate_patches_or_pr_event_or_pr_updates( | |||
| 460 | let use_pr = parent_is_pr || git_repo.are_commits_too_big_for_patches(ahead); | 460 | let use_pr = parent_is_pr || git_repo.are_commits_too_big_for_patches(ahead); |
| 461 | 461 | ||
| 462 | if use_pr { | 462 | if use_pr { |
| 463 | let tip = ahead.first().context("no commits")?; // ahead is youngest first | ||
| 464 | let first_commit = ahead.last().context("no commits")?; | ||
| 463 | select_servers_push_refs_and_generate_pr_or_pr_update_event( | 465 | select_servers_push_refs_and_generate_pr_or_pr_update_event( |
| 464 | client, | 466 | client, |
| 465 | git_repo, | 467 | git_repo, |
| 466 | repo_ref, | 468 | repo_ref, |
| 467 | ahead.first().context("no commits to push")?, | 469 | tip, |
| 470 | first_commit, | ||
| 471 | git_repo.get_commit_parent(first_commit).ok().as_ref(), | ||
| 468 | user_ref, | 472 | user_ref, |
| 469 | root_proposal, | 473 | root_proposal, |
| 470 | &None, | 474 | &None, |
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index 0e4a572..6ae0cda 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs | |||
| @@ -206,11 +206,15 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 206 | commits.reverse(); | 206 | commits.reverse(); |
| 207 | 207 | ||
| 208 | let events = if as_pr { | 208 | let events = if as_pr { |
| 209 | let tip = commits.last().context("no commits")?; // commits has been reversed to oldest first | ||
| 210 | let first_commit = commits.first().context("no commits")?; | ||
| 209 | select_servers_push_refs_and_generate_pr_or_pr_update_event( | 211 | select_servers_push_refs_and_generate_pr_or_pr_update_event( |
| 210 | &client, | 212 | &client, |
| 211 | &git_repo, | 213 | &git_repo, |
| 212 | &repo_ref, | 214 | &repo_ref, |
| 213 | commits.last().context("no commits")?, | 215 | tip, |
| 216 | first_commit, | ||
| 217 | git_repo.get_commit_parent(first_commit).ok().as_ref(), | ||
| 214 | &mut user_ref, | 218 | &mut user_ref, |
| 215 | root_proposal.as_ref(), | 219 | root_proposal.as_ref(), |
| 216 | &cover_letter_title_description, | 220 | &cover_letter_title_description, |
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index 3d5297f..06573eb 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs | |||
| @@ -420,6 +420,7 @@ impl RepoActions for Repo { | |||
| 420 | Ok(diff.deltas().len().gt(&0)) | 420 | Ok(diff.deltas().len().gt(&0)) |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | // youngest first | ||
| 423 | fn get_commits_ahead_behind( | 424 | fn get_commits_ahead_behind( |
| 424 | &self, | 425 | &self, |
| 425 | base_commit: &Sha1Hash, | 426 | base_commit: &Sha1Hash, |
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() |
diff --git a/src/lib/push.rs b/src/lib/push.rs index 28692f3..aafcf35 100644 --- a/src/lib/push.rs +++ b/src/lib/push.rs | |||
| @@ -378,6 +378,8 @@ pub async fn select_servers_push_refs_and_generate_pr_or_pr_update_event( | |||
| 378 | git_repo: &Repo, | 378 | git_repo: &Repo, |
| 379 | repo_ref: &RepoRef, | 379 | repo_ref: &RepoRef, |
| 380 | tip: &Sha1Hash, | 380 | tip: &Sha1Hash, |
| 381 | first_commit: &Sha1Hash, | ||
| 382 | merge_base: Option<&Sha1Hash>, | ||
| 381 | user_ref: &mut UserRef, | 383 | user_ref: &mut UserRef, |
| 382 | root_proposal: Option<&Event>, | 384 | root_proposal: Option<&Event>, |
| 383 | title_description_overide: &Option<(String, String)>, | 385 | title_description_overide: &Option<(String, String)>, |
| @@ -441,6 +443,8 @@ pub async fn select_servers_push_refs_and_generate_pr_or_pr_update_event( | |||
| 441 | git_repo, | 443 | git_repo, |
| 442 | repo_ref, | 444 | repo_ref, |
| 443 | tip, | 445 | tip, |
| 446 | first_commit, | ||
| 447 | merge_base, | ||
| 444 | user_ref, | 448 | user_ref, |
| 445 | root_proposal, | 449 | root_proposal, |
| 446 | title_description_overide, | 450 | title_description_overide, |
| @@ -673,6 +677,8 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event( | |||
| 673 | git_repo: &Repo, | 677 | git_repo: &Repo, |
| 674 | repo_ref: &RepoRef, | 678 | repo_ref: &RepoRef, |
| 675 | tip: &Sha1Hash, | 679 | tip: &Sha1Hash, |
| 680 | first_commit: &Sha1Hash, | ||
| 681 | merge_base: Option<&Sha1Hash>, | ||
| 676 | user_ref: &UserRef, | 682 | user_ref: &UserRef, |
| 677 | root_proposal: Option<&Event>, | 683 | root_proposal: Option<&Event>, |
| 678 | title_description_overide: &Option<(String, String)>, | 684 | title_description_overide: &Option<(String, String)>, |
| @@ -695,6 +701,8 @@ pub async fn push_refs_and_generate_pr_or_pr_update_event( | |||
| 695 | root_proposal, | 701 | root_proposal, |
| 696 | title_description_overide, | 702 | title_description_overide, |
| 697 | tip, | 703 | tip, |
| 704 | first_commit, | ||
| 705 | merge_base, | ||
| 698 | &[clone_url], | 706 | &[clone_url], |
| 699 | &[], | 707 | &[], |
| 700 | )? | 708 | )? |