upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sub_commands/push.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-09-13 17:09:10 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-09-13 17:23:09 +0100
commit61b130e61e3ba88d61f75dd2f6a201e700e7dc01 (patch)
tree3e9a211a81e14a5daa1beb8899275768b9c97d4b /src/sub_commands/push.rs
parent36763dc0d821425e088adefd16dc7c4bf3b30f3b (diff)
fix(ngit): pull and push find pr from branch
as since cl.get_branch_name has been introduced branch names could be prefixed with a pr and sometimes postfixed with an event id with the fix your branch could be called `article-editor` or `pr/article-editor` if you are logged in as the author of the PR (git config nostr.npub matches the PR author) or `article-editor(3fbba0ec)` which is what it would be named if you weren't logged in as the author and checked out the branch on a remote with the nostr url.
Diffstat (limited to 'src/sub_commands/push.rs')
-rw-r--r--src/sub_commands/push.rs20
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 @@
1use anyhow::{bail, Context, Result}; 1use anyhow::{bail, Context, Result};
2use nostr_sdk::PublicKey;
2 3
3#[cfg(not(test))] 4#[cfg(not(test))]
4use crate::client::Client; 5use 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