diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 596cd68..b997ea7 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -321,10 +321,15 @@ async fn process_proposal_refspecs( | |||
| 321 | { | 321 | { |
| 322 | if refspec.starts_with('+') { | 322 | if refspec.starts_with('+') { |
| 323 | // force push | 323 | // force push |
| 324 | let (_, main_tip) = git_repo.get_main_or_master_branch()?; | 324 | let (main_branch_name, main_tip) = git_repo.get_main_or_master_branch()?; |
| 325 | let (mut ahead, _) = | 325 | let (mut ahead, _) = |
| 326 | git_repo.get_commits_ahead_behind(&main_tip, &tip_of_pushed_branch)?; | 326 | git_repo.get_commits_ahead_behind(&main_tip, &tip_of_pushed_branch)?; |
| 327 | ahead.reverse(); | 327 | ahead.reverse(); |
| 328 | if ahead.is_empty() { | ||
| 329 | bail!( | ||
| 330 | "cannot push '{from}' as proposal as branch isn't ahead of '{main_branch_name}'" | ||
| 331 | ); | ||
| 332 | } | ||
| 328 | for patch in generate_patches_or_pr_event_or_pr_updates( | 333 | for patch in generate_patches_or_pr_event_or_pr_updates( |
| 329 | git_repo, | 334 | git_repo, |
| 330 | repo_ref, | 335 | repo_ref, |
| @@ -356,6 +361,11 @@ async fn process_proposal_refspecs( | |||
| 356 | }; | 361 | }; |
| 357 | let mut parent_patch = tip_patch.clone(); | 362 | let mut parent_patch = tip_patch.clone(); |
| 358 | ahead.reverse(); | 363 | ahead.reverse(); |
| 364 | if ahead.is_empty() { | ||
| 365 | bail!( | ||
| 366 | "cannot push '{from}' as proposal as branch isn't ahead of proposal on nostr" | ||
| 367 | ); | ||
| 368 | } | ||
| 359 | if proposal.kind.eq(&KIND_PULL_REQUEST) | 369 | if proposal.kind.eq(&KIND_PULL_REQUEST) |
| 360 | || are_commits_too_big_for_patches(git_repo, &ahead) | 370 | || are_commits_too_big_for_patches(git_repo, &ahead) |
| 361 | { | 371 | { |
| @@ -418,10 +428,15 @@ async fn process_proposal_refspecs( | |||
| 418 | } | 428 | } |
| 419 | } else { | 429 | } else { |
| 420 | // TODO new proposal / couldn't find exisiting proposal | 430 | // TODO new proposal / couldn't find exisiting proposal |
| 421 | let (_, main_tip) = git_repo.get_main_or_master_branch()?; | 431 | let (main_branch_name, main_tip) = git_repo.get_main_or_master_branch()?; |
| 422 | let (mut ahead, _) = | 432 | let (mut ahead, _) = |
| 423 | git_repo.get_commits_ahead_behind(&main_tip, &tip_of_pushed_branch)?; | 433 | git_repo.get_commits_ahead_behind(&main_tip, &tip_of_pushed_branch)?; |
| 424 | ahead.reverse(); | 434 | ahead.reverse(); |
| 435 | if ahead.is_empty() { | ||
| 436 | bail!( | ||
| 437 | "cannot push '{from}' as proposal as branch isn't ahead of '{main_branch_name}'" | ||
| 438 | ); | ||
| 439 | } | ||
| 425 | for event in generate_patches_or_pr_event_or_pr_updates( | 440 | for event in generate_patches_or_pr_event_or_pr_updates( |
| 426 | git_repo, repo_ref, &ahead, user_ref, None, signer, term, | 441 | git_repo, repo_ref, &ahead, user_ref, None, signer, term, |
| 427 | ) | 442 | ) |
| @@ -513,11 +528,11 @@ async fn generate_patches_or_pr_event_or_pr_updates( | |||
| 513 | } | 528 | } |
| 514 | } | 529 | } |
| 515 | if unsigned_pr_event.is_none() { | 530 | if unsigned_pr_event.is_none() { |
| 516 | // TODO get fallback grasp servers that aren't in repo_grasps cycle | 531 | // TODO get grasp_default_set servers that aren't in repo_grasps |
| 517 | // through until one succeeds TODO create personal-fork | 532 | // cycle through until one succeeds TODO create |
| 518 | // announcement with grasp servers and push, after a few seconds | 533 | // personal-fork announcement with grasp servers and |
| 519 | // push ref/nostr/eventid. if one success break out of | 534 | // push, after a few seconds push ref/nostr/eventid. if |
| 520 | // for loop and continue | 535 | // one success break out of for loop and continue |
| 521 | } | 536 | } |
| 522 | if let Some(unsigned_pr_event) = unsigned_pr_event { | 537 | if let Some(unsigned_pr_event) = unsigned_pr_event { |
| 523 | let pr_event = sign_draft_event( | 538 | let pr_event = sign_draft_event( |