upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/main.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-17 10:42:33 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-17 11:38:26 +0000
commitfe5addc2a61022824e83c3523a83fce7690ca8e8 (patch)
treeb9791bd9447828ebd77b69c3989b53bb47c0cd70 /src/bin/git_remote_nostr/main.rs
parentf84b658530c0c0eaaaa0473add8c8c359fa6b09e (diff)
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
Diffstat (limited to 'src/bin/git_remote_nostr/main.rs')
-rw-r--r--src/bin/git_remote_nostr/main.rs21
1 files changed, 21 insertions, 0 deletions
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;
24 24
25use crate::{client::Client, git::Repo}; 25use crate::{client::Client, git::Repo};
26 26
27#[derive(Default, Clone)]
28struct PushOptions {
29 title: Option<String>,
30 description: Option<String>,
31}
32
27mod fetch; 33mod fetch;
28mod list; 34mod list;
29mod push; 35mod push;
@@ -71,6 +77,7 @@ async fn main() -> Result<()> {
71 let mut line = String::new(); 77 let mut line = String::new();
72 78
73 let mut list_outputs = None; 79 let mut list_outputs = None;
80 let mut push_options: PushOptions = PushOptions::default();
74 loop { 81 loop {
75 let tokens = read_line(&stdin, &mut line)?; 82 let tokens = read_line(&stdin, &mut line)?;
76 83
@@ -79,11 +86,23 @@ async fn main() -> Result<()> {
79 println!("option"); 86 println!("option");
80 println!("push"); 87 println!("push");
81 println!("fetch"); 88 println!("fetch");
89 println!("push-options");
82 println!(); 90 println!();
83 } 91 }
84 ["option", "verbosity"] => { 92 ["option", "verbosity"] => {
85 println!("ok"); 93 println!("ok");
86 } 94 }
95 ["option", "push-option", rest @ ..] => {
96 let option = rest.join(" ");
97 if let Some((key, value)) = option.split_once('=') {
98 match key {
99 "title" => push_options.title = Some(value.to_string()),
100 "description" => push_options.description = Some(value.to_string()),
101 _ => {}
102 }
103 }
104 println!("ok");
105 }
87 ["option", ..] => { 106 ["option", ..] => {
88 println!("unsupported"); 107 println!("unsupported");
89 } 108 }
@@ -98,8 +117,10 @@ async fn main() -> Result<()> {
98 refspec, 117 refspec,
99 &client, 118 &client,
100 list_outputs.clone(), 119 list_outputs.clone(),
120 push_options.title.as_ref().zip(push_options.description.as_ref()).map(|(t, d)| (t.clone(), d.clone())),
101 ) 121 )
102 .await?; 122 .await?;
123 push_options = PushOptions::default();
103 } 124 }
104 ["list"] => { 125 ["list"] => {
105 list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?); 126 list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?);