diff options
Diffstat (limited to 'src/sub_commands/push.rs')
| -rw-r--r-- | src/sub_commands/push.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 7a82c7a..15baad9 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | use anyhow::{bail, Context, Result}; | 1 | use anyhow::{bail, Context, Result}; |
| 2 | use nostr_sdk::PublicKey; | ||
| 2 | 3 | ||
| 3 | #[cfg(not(test))] | 4 | #[cfg(not(test))] |
| 4 | use crate::client::Client; | 5 | use crate::client::Client; |
| @@ -17,10 +18,8 @@ use crate::{ | |||
| 17 | get_most_recent_patch_with_ancestors, get_proposals_and_revisions_from_cache, | 18 | get_most_recent_patch_with_ancestors, get_proposals_and_revisions_from_cache, |
| 18 | tag_value, | 19 | tag_value, |
| 19 | }, | 20 | }, |
| 20 | send::{ | 21 | pull::is_event_proposal_root_for_branch, |
| 21 | event_is_revision_root, event_to_cover_letter, generate_patch_event, | 22 | send::{generate_patch_event, identify_ahead_behind, send_events}, |
| 22 | identify_ahead_behind, send_events, | ||
| 23 | }, | ||
| 24 | }, | 23 | }, |
| 25 | }; | 24 | }; |
| 26 | 25 | ||
| @@ -62,15 +61,18 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 62 | 61 | ||
| 63 | let repo_ref = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?; | 62 | let repo_ref = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?; |
| 64 | 63 | ||
| 64 | let logged_in_public_key = | ||
| 65 | if let Ok(Some(npub)) = git_repo.get_git_config_item("nostr.npub", None) { | ||
| 66 | PublicKey::parse(npub).ok() | ||
| 67 | } else { | ||
| 68 | None | ||
| 69 | }; | ||
| 70 | |||
| 65 | let proposal_root_event = | 71 | let proposal_root_event = |
| 66 | get_proposals_and_revisions_from_cache(git_repo_path, repo_ref.coordinates()) | 72 | get_proposals_and_revisions_from_cache(git_repo_path, repo_ref.coordinates()) |
| 67 | .await? | 73 | .await? |
| 68 | .iter() | 74 | .iter() |
| 69 | .find(|e| { | 75 | .find(|e| is_event_proposal_root_for_branch(e, &branch_name, &logged_in_public_key)) |
| 70 | event_to_cover_letter(e) | ||
| 71 | .is_ok_and(|cl| cl.get_branch_name().is_ok_and(|s| s.eq(&branch_name))) | ||
| 72 | && !event_is_revision_root(e) | ||
| 73 | }) | ||
| 74 | .context("cannot find proposal that matches the current branch name")? | 76 | .context("cannot find proposal that matches the current branch name")? |
| 75 | .clone(); | 77 | .clone(); |
| 76 | 78 | ||