diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/git_remote_helper.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs index ff053f6..6997dfa 100644 --- a/src/git_remote_helper.rs +++ b/src/git_remote_helper.rs | |||
| @@ -458,6 +458,35 @@ fn get_curent_user(git_repo: &Repo) -> Result<Option<PublicKey>> { | |||
| 458 | ) | 458 | ) |
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | async fn get_all_proposals( | ||
| 462 | git_repo: &Repo, | ||
| 463 | repo_ref: &RepoRef, | ||
| 464 | ) -> Result<HashMap<EventId, (Event, Vec<Event>)>> { | ||
| 465 | let git_repo_path = git_repo.get_path()?; | ||
| 466 | let proposals: Vec<nostr::Event> = | ||
| 467 | get_proposals_and_revisions_from_cache(git_repo_path, repo_ref.coordinates()) | ||
| 468 | .await? | ||
| 469 | .iter() | ||
| 470 | .filter(|e| !event_is_revision_root(e)) | ||
| 471 | .cloned() | ||
| 472 | .collect(); | ||
| 473 | |||
| 474 | let mut all_proposals = HashMap::new(); | ||
| 475 | |||
| 476 | for proposal in proposals { | ||
| 477 | if let Ok(commits_events) = | ||
| 478 | get_all_proposal_patch_events_from_cache(git_repo_path, repo_ref, &proposal.id).await | ||
| 479 | { | ||
| 480 | if let Ok(most_recent_proposal_patch_chain) = | ||
| 481 | get_most_recent_patch_with_ancestors(commits_events.clone()) | ||
| 482 | { | ||
| 483 | all_proposals.insert(proposal.id(), (proposal, most_recent_proposal_patch_chain)); | ||
| 484 | } | ||
| 485 | } | ||
| 486 | } | ||
| 487 | Ok(all_proposals) | ||
| 488 | } | ||
| 489 | |||
| 461 | async fn fetch( | 490 | async fn fetch( |
| 462 | git_repo: &Repo, | 491 | git_repo: &Repo, |
| 463 | repo_ref: &RepoRef, | 492 | repo_ref: &RepoRef, |
| @@ -688,7 +717,7 @@ async fn push( | |||
| 688 | 717 | ||
| 689 | let mut rejected_proposal_refspecs = vec![]; | 718 | let mut rejected_proposal_refspecs = vec![]; |
| 690 | if !proposal_refspecs.is_empty() { | 719 | if !proposal_refspecs.is_empty() { |
| 691 | let open_proposals = get_open_proposals(git_repo, repo_ref).await?; | 720 | let all_proposals = get_all_proposals(git_repo, repo_ref).await?; |
| 692 | let current_user = get_curent_user(git_repo)?; | 721 | let current_user = get_curent_user(git_repo)?; |
| 693 | 722 | ||
| 694 | for refspec in &proposal_refspecs { | 723 | for refspec in &proposal_refspecs { |
| @@ -696,7 +725,7 @@ async fn push( | |||
| 696 | let tip_of_pushed_branch = git_repo.get_commit_or_tip_of_reference(from)?; | 725 | let tip_of_pushed_branch = git_repo.get_commit_or_tip_of_reference(from)?; |
| 697 | 726 | ||
| 698 | if let Some((_, (proposal, patches))) = | 727 | if let Some((_, (proposal, patches))) = |
| 699 | find_proposal_and_patches_by_branch_name(to, &open_proposals, ¤t_user) | 728 | find_proposal_and_patches_by_branch_name(to, &all_proposals, ¤t_user) |
| 700 | { | 729 | { |
| 701 | if [repo_ref.maintainers.clone(), vec![proposal.author()]] | 730 | if [repo_ref.maintainers.clone(), vec![proposal.author()]] |
| 702 | .concat() | 731 | .concat() |