From fe5addc2a61022824e83c3523a83fce7690ca8e8 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 17 Feb 2026 10:42:33 +0000 Subject: 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 --- src/bin/git_remote_nostr/main.rs | 21 +++++++++++++++++++++ src/bin/git_remote_nostr/push.rs | 22 ++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'src/bin') diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index d7151d8..e57dff7 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -24,6 +24,12 @@ use nostr::nips::nip19::Nip19Coordinate; use crate::{client::Client, git::Repo}; +#[derive(Default, Clone)] +struct PushOptions { + title: Option, + description: Option, +} + mod fetch; mod list; mod push; @@ -71,6 +77,7 @@ async fn main() -> Result<()> { let mut line = String::new(); let mut list_outputs = None; + let mut push_options: PushOptions = PushOptions::default(); loop { let tokens = read_line(&stdin, &mut line)?; @@ -79,11 +86,23 @@ async fn main() -> Result<()> { println!("option"); println!("push"); println!("fetch"); + println!("push-options"); println!(); } ["option", "verbosity"] => { println!("ok"); } + ["option", "push-option", rest @ ..] => { + let option = rest.join(" "); + if let Some((key, value)) = option.split_once('=') { + match key { + "title" => push_options.title = Some(value.to_string()), + "description" => push_options.description = Some(value.to_string()), + _ => {} + } + } + println!("ok"); + } ["option", ..] => { println!("unsupported"); } @@ -98,8 +117,10 @@ async fn main() -> Result<()> { refspec, &client, list_outputs.clone(), + push_options.title.as_ref().zip(push_options.description.as_ref()).map(|(t, d)| (t.clone(), d.clone())), ) .await?; + push_options = PushOptions::default(); } ["list"] => { list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?); 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( initial_refspec: &str, client: &Client, list_outputs: Option, bool)>>, + title_description: Option<(String, String)>, ) -> Result<()> { let refspecs = get_refspecs_from_push_batch(stdin, initial_refspec)?; @@ -129,6 +130,7 @@ pub async fn run_push( client, existing_state, &term, + title_description.as_ref(), ) .await?; @@ -174,6 +176,7 @@ pub async fn run_push( } #[allow(clippy::too_many_lines)] +#[allow(clippy::too_many_arguments)] async fn create_and_publish_events_and_proposals( git_repo: &Repo, repo_ref: &RepoRef, @@ -182,6 +185,7 @@ async fn create_and_publish_events_and_proposals( client: &Client, existing_state: HashMap, term: &Term, + title_description: Option<&(String, String)>, ) -> Result<(Vec, bool)> { let (signer, mut user_ref, _) = load_existing_login( &Some(git_repo), @@ -276,6 +280,7 @@ async fn create_and_publish_events_and_proposals( &mut user_ref, &signer, term, + title_description, ) .await?; for e in proposal_events { @@ -300,6 +305,7 @@ async fn create_and_publish_events_and_proposals( } #[allow(clippy::too_many_lines)] +#[allow(clippy::too_many_arguments)] async fn process_proposal_refspecs( client: &Client, git_repo: &Repo, @@ -308,6 +314,7 @@ async fn process_proposal_refspecs( user_ref: &mut UserRef, signer: &Arc, term: &Term, + title_description: Option<&(String, String)>, ) -> Result<(Vec, Vec)> { let mut events = vec![]; let mut rejected_proposal_refspecs = vec![]; @@ -349,6 +356,7 @@ async fn process_proposal_refspecs( Some(proposal), signer, term, + title_description, ) .await? { @@ -389,6 +397,7 @@ async fn process_proposal_refspecs( Some(proposal), signer, term, + title_description, ) .await? { @@ -451,7 +460,15 @@ async fn process_proposal_refspecs( ); } for event in generate_patches_or_pr_event_or_pr_updates( - client, git_repo, repo_ref, &ahead, user_ref, None, signer, term, + client, + git_repo, + repo_ref, + &ahead, + user_ref, + None, + signer, + term, + title_description, ) .await? { @@ -474,6 +491,7 @@ async fn generate_patches_or_pr_event_or_pr_updates( root_proposal: Option<&Event>, signer: &Arc, term: &Term, + title_description: Option<&(String, String)>, ) -> Result> { let parent_is_pr = root_proposal.is_some_and(|proposal| proposal.kind.eq(&KIND_PULL_REQUEST)); 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( git_repo.get_commit_parent(first_commit).ok().as_ref(), user_ref, root_proposal, - &None, + &title_description.map(|(t, d)| (t.clone(), d.clone())), signer, false, term, -- cgit v1.2.3