diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-17 10:42:33 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-17 11:38:26 +0000 |
| commit | fe5addc2a61022824e83c3523a83fce7690ca8e8 (patch) | |
| tree | b9791bd9447828ebd77b69c3989b53bb47c0cd70 /src/bin/git_remote_nostr/push.rs | |
| parent | f84b658530c0c0eaaaa0473add8c8c359fa6b09e (diff) | |
feat: add push-options for title and description to git-remote-nostr
Allows setting PR title and description via git push options:
git push --push-option=title="My PR" \
--push-option=description="Details" origin pr/branch
Diffstat (limited to 'src/bin/git_remote_nostr/push.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index c2f4ddd..f20c264 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -52,6 +52,7 @@ pub async fn run_push( | |||
| 52 | initial_refspec: &str, | 52 | initial_refspec: &str, |
| 53 | client: &Client, | 53 | client: &Client, |
| 54 | list_outputs: Option<HashMap<String, (HashMap<String, String>, bool)>>, | 54 | list_outputs: Option<HashMap<String, (HashMap<String, String>, bool)>>, |
| 55 | title_description: Option<(String, String)>, | ||
| 55 | ) -> Result<()> { | 56 | ) -> Result<()> { |
| 56 | let refspecs = get_refspecs_from_push_batch(stdin, initial_refspec)?; | 57 | let refspecs = get_refspecs_from_push_batch(stdin, initial_refspec)?; |
| 57 | 58 | ||
| @@ -129,6 +130,7 @@ pub async fn run_push( | |||
| 129 | client, | 130 | client, |
| 130 | existing_state, | 131 | existing_state, |
| 131 | &term, | 132 | &term, |
| 133 | title_description.as_ref(), | ||
| 132 | ) | 134 | ) |
| 133 | .await?; | 135 | .await?; |
| 134 | 136 | ||
| @@ -174,6 +176,7 @@ pub async fn run_push( | |||
| 174 | } | 176 | } |
| 175 | 177 | ||
| 176 | #[allow(clippy::too_many_lines)] | 178 | #[allow(clippy::too_many_lines)] |
| 179 | #[allow(clippy::too_many_arguments)] | ||
| 177 | async fn create_and_publish_events_and_proposals( | 180 | async fn create_and_publish_events_and_proposals( |
| 178 | git_repo: &Repo, | 181 | git_repo: &Repo, |
| 179 | repo_ref: &RepoRef, | 182 | repo_ref: &RepoRef, |
| @@ -182,6 +185,7 @@ async fn create_and_publish_events_and_proposals( | |||
| 182 | client: &Client, | 185 | client: &Client, |
| 183 | existing_state: HashMap<String, String>, | 186 | existing_state: HashMap<String, String>, |
| 184 | term: &Term, | 187 | term: &Term, |
| 188 | title_description: Option<&(String, String)>, | ||
| 185 | ) -> Result<(Vec<String>, bool)> { | 189 | ) -> Result<(Vec<String>, bool)> { |
| 186 | let (signer, mut user_ref, _) = load_existing_login( | 190 | let (signer, mut user_ref, _) = load_existing_login( |
| 187 | &Some(git_repo), | 191 | &Some(git_repo), |
| @@ -276,6 +280,7 @@ async fn create_and_publish_events_and_proposals( | |||
| 276 | &mut user_ref, | 280 | &mut user_ref, |
| 277 | &signer, | 281 | &signer, |
| 278 | term, | 282 | term, |
| 283 | title_description, | ||
| 279 | ) | 284 | ) |
| 280 | .await?; | 285 | .await?; |
| 281 | for e in proposal_events { | 286 | for e in proposal_events { |
| @@ -300,6 +305,7 @@ async fn create_and_publish_events_and_proposals( | |||
| 300 | } | 305 | } |
| 301 | 306 | ||
| 302 | #[allow(clippy::too_many_lines)] | 307 | #[allow(clippy::too_many_lines)] |
| 308 | #[allow(clippy::too_many_arguments)] | ||
| 303 | async fn process_proposal_refspecs( | 309 | async fn process_proposal_refspecs( |
| 304 | client: &Client, | 310 | client: &Client, |
| 305 | git_repo: &Repo, | 311 | git_repo: &Repo, |
| @@ -308,6 +314,7 @@ async fn process_proposal_refspecs( | |||
| 308 | user_ref: &mut UserRef, | 314 | user_ref: &mut UserRef, |
| 309 | signer: &Arc<dyn NostrSigner>, | 315 | signer: &Arc<dyn NostrSigner>, |
| 310 | term: &Term, | 316 | term: &Term, |
| 317 | title_description: Option<&(String, String)>, | ||
| 311 | ) -> Result<(Vec<Event>, Vec<String>)> { | 318 | ) -> Result<(Vec<Event>, Vec<String>)> { |
| 312 | let mut events = vec![]; | 319 | let mut events = vec![]; |
| 313 | let mut rejected_proposal_refspecs = vec![]; | 320 | let mut rejected_proposal_refspecs = vec![]; |
| @@ -349,6 +356,7 @@ async fn process_proposal_refspecs( | |||
| 349 | Some(proposal), | 356 | Some(proposal), |
| 350 | signer, | 357 | signer, |
| 351 | term, | 358 | term, |
| 359 | title_description, | ||
| 352 | ) | 360 | ) |
| 353 | .await? | 361 | .await? |
| 354 | { | 362 | { |
| @@ -389,6 +397,7 @@ async fn process_proposal_refspecs( | |||
| 389 | Some(proposal), | 397 | Some(proposal), |
| 390 | signer, | 398 | signer, |
| 391 | term, | 399 | term, |
| 400 | title_description, | ||
| 392 | ) | 401 | ) |
| 393 | .await? | 402 | .await? |
| 394 | { | 403 | { |
| @@ -451,7 +460,15 @@ async fn process_proposal_refspecs( | |||
| 451 | ); | 460 | ); |
| 452 | } | 461 | } |
| 453 | for event in generate_patches_or_pr_event_or_pr_updates( | 462 | for event in generate_patches_or_pr_event_or_pr_updates( |
| 454 | client, git_repo, repo_ref, &ahead, user_ref, None, signer, term, | 463 | client, |
| 464 | git_repo, | ||
| 465 | repo_ref, | ||
| 466 | &ahead, | ||
| 467 | user_ref, | ||
| 468 | None, | ||
| 469 | signer, | ||
| 470 | term, | ||
| 471 | title_description, | ||
| 455 | ) | 472 | ) |
| 456 | .await? | 473 | .await? |
| 457 | { | 474 | { |
| @@ -474,6 +491,7 @@ async fn generate_patches_or_pr_event_or_pr_updates( | |||
| 474 | root_proposal: Option<&Event>, | 491 | root_proposal: Option<&Event>, |
| 475 | signer: &Arc<dyn NostrSigner>, | 492 | signer: &Arc<dyn NostrSigner>, |
| 476 | term: &Term, | 493 | term: &Term, |
| 494 | title_description: Option<&(String, String)>, | ||
| 477 | ) -> Result<Vec<Event>> { | 495 | ) -> Result<Vec<Event>> { |
| 478 | let parent_is_pr = root_proposal.is_some_and(|proposal| proposal.kind.eq(&KIND_PULL_REQUEST)); | 496 | let parent_is_pr = root_proposal.is_some_and(|proposal| proposal.kind.eq(&KIND_PULL_REQUEST)); |
| 479 | let use_pr = parent_is_pr || git_repo.are_commits_too_big_for_patches(ahead); | 497 | let use_pr = parent_is_pr || git_repo.are_commits_too_big_for_patches(ahead); |
| @@ -490,7 +508,7 @@ async fn generate_patches_or_pr_event_or_pr_updates( | |||
| 490 | git_repo.get_commit_parent(first_commit).ok().as_ref(), | 508 | git_repo.get_commit_parent(first_commit).ok().as_ref(), |
| 491 | user_ref, | 509 | user_ref, |
| 492 | root_proposal, | 510 | root_proposal, |
| 493 | &None, | 511 | &title_description.map(|(t, d)| (t.clone(), d.clone())), |
| 494 | signer, | 512 | signer, |
| 495 | false, | 513 | false, |
| 496 | term, | 514 | term, |