upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr/push.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-25 16:46:02 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 15:26:14 +0000
commit5c305e922e19e4ac65c6a1473be67145a1c73f2b (patch)
treefb03feb94b324297df4b3560af379c6c89b1ed6e /src/bin/git_remote_nostr/push.rs
parent3017faf6d346fa9328c5979c6e9c6bc471bd3942 (diff)
feat: forward unrecognised push options to git servers
Any -o option passed to `git push` that is not handled by ngit (title, description) is forwarded verbatim to the git server via git2::PushOptions::remote_push_options. This allows options such as `-o secret-scanning.skip` to pass through transparently. `ngit send` gains a matching -o / --push-option flag for the same purpose.
Diffstat (limited to 'src/bin/git_remote_nostr/push.rs')
-rw-r--r--src/bin/git_remote_nostr/push.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index b64cdd9..06624f4 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -45,6 +45,7 @@ use repo_state::RepoState;
45use crate::{client::Client, git::Repo}; 45use crate::{client::Client, git::Repo};
46 46
47#[allow(clippy::too_many_lines)] 47#[allow(clippy::too_many_lines)]
48#[allow(clippy::too_many_arguments)]
48#[allow(clippy::type_complexity)] 49#[allow(clippy::type_complexity)]
49pub async fn run_push( 50pub async fn run_push(
50 git_repo: &Repo, 51 git_repo: &Repo,
@@ -54,6 +55,7 @@ pub async fn run_push(
54 client: &mut Client, 55 client: &mut Client,
55 list_outputs: Option<HashMap<String, (HashMap<String, String>, bool)>>, 56 list_outputs: Option<HashMap<String, (HashMap<String, String>, bool)>>,
56 title_description: Option<(String, String)>, 57 title_description: Option<(String, String)>,
58 git_server_push_options: Vec<String>,
57) -> Result<()> { 59) -> Result<()> {
58 let refspecs = get_refspecs_from_push_batch(stdin, initial_refspec)?; 60 let refspecs = get_refspecs_from_push_batch(stdin, initial_refspec)?;
59 61
@@ -132,6 +134,7 @@ pub async fn run_push(
132 existing_state, 134 existing_state,
133 &term, 135 &term,
134 title_description.as_ref(), 136 title_description.as_ref(),
137 &git_server_push_options,
135 ) 138 )
136 .await?; 139 .await?;
137 140
@@ -159,6 +162,8 @@ pub async fn run_push(
159 .cloned() 162 .cloned()
160 .collect::<Vec<String>>(); 163 .collect::<Vec<String>>();
161 if !refspecs.is_empty() { 164 if !refspecs.is_empty() {
165 let push_options_refs: Vec<&str> =
166 git_server_push_options.iter().map(String::as_str).collect();
162 let _ = push_to_remote( 167 let _ = push_to_remote(
163 git_repo, 168 git_repo,
164 &git_server_url, 169 &git_server_url,
@@ -166,6 +171,7 @@ pub async fn run_push(
166 &remote_refspecs, 171 &remote_refspecs,
167 &term, 172 &term,
168 is_grasp_server_clone_url(&git_server_url), 173 is_grasp_server_clone_url(&git_server_url),
174 &push_options_refs,
169 ); 175 );
170 } 176 }
171 } 177 }
@@ -187,6 +193,7 @@ async fn create_and_publish_events_and_proposals(
187 existing_state: HashMap<String, String>, 193 existing_state: HashMap<String, String>,
188 term: &Term, 194 term: &Term,
189 title_description: Option<&(String, String)>, 195 title_description: Option<&(String, String)>,
196 git_server_push_options: &[String],
190) -> Result<(Vec<String>, bool)> { 197) -> Result<(Vec<String>, bool)> {
191 let (signer, mut user_ref, _) = load_existing_login( 198 let (signer, mut user_ref, _) = load_existing_login(
192 &Some(git_repo), 199 &Some(git_repo),
@@ -281,6 +288,7 @@ async fn create_and_publish_events_and_proposals(
281 &signer, 288 &signer,
282 term, 289 term,
283 title_description, 290 title_description,
291 git_server_push_options,
284 ) 292 )
285 .await?; 293 .await?;
286 for e in proposal_events { 294 for e in proposal_events {
@@ -315,6 +323,7 @@ async fn process_proposal_refspecs(
315 signer: &Arc<dyn NostrSigner>, 323 signer: &Arc<dyn NostrSigner>,
316 term: &Term, 324 term: &Term,
317 title_description: Option<&(String, String)>, 325 title_description: Option<&(String, String)>,
326 git_server_push_options: &[String],
318) -> Result<(Vec<Event>, Vec<String>)> { 327) -> Result<(Vec<Event>, Vec<String>)> {
319 let mut events = vec![]; 328 let mut events = vec![];
320 let mut rejected_proposal_refspecs = vec![]; 329 let mut rejected_proposal_refspecs = vec![];
@@ -357,6 +366,7 @@ async fn process_proposal_refspecs(
357 signer, 366 signer,
358 term, 367 term,
359 title_description, 368 title_description,
369 git_server_push_options,
360 ) 370 )
361 .await? 371 .await?
362 { 372 {
@@ -398,6 +408,7 @@ async fn process_proposal_refspecs(
398 signer, 408 signer,
399 term, 409 term,
400 title_description, 410 title_description,
411 git_server_push_options,
401 ) 412 )
402 .await? 413 .await?
403 { 414 {
@@ -469,6 +480,7 @@ async fn process_proposal_refspecs(
469 signer, 480 signer,
470 term, 481 term,
471 title_description, 482 title_description,
483 git_server_push_options,
472 ) 484 )
473 .await? 485 .await?
474 { 486 {
@@ -492,6 +504,7 @@ async fn generate_patches_or_pr_event_or_pr_updates(
492 signer: &Arc<dyn NostrSigner>, 504 signer: &Arc<dyn NostrSigner>,
493 term: &Term, 505 term: &Term,
494 title_description: Option<&(String, String)>, 506 title_description: Option<&(String, String)>,
507 git_server_push_options: &[String],
495) -> Result<Vec<Event>> { 508) -> Result<Vec<Event>> {
496 let parent_is_pr = root_proposal.is_some_and(|proposal| proposal.kind.eq(&KIND_PULL_REQUEST)); 509 let parent_is_pr = root_proposal.is_some_and(|proposal| proposal.kind.eq(&KIND_PULL_REQUEST));
497 let use_pr = parent_is_pr || git_repo.are_commits_too_big_for_patches(ahead); 510 let use_pr = parent_is_pr || git_repo.are_commits_too_big_for_patches(ahead);
@@ -499,6 +512,8 @@ async fn generate_patches_or_pr_event_or_pr_updates(
499 if use_pr { 512 if use_pr {
500 let tip = ahead.first().context("no commits")?; // ahead is youngest first 513 let tip = ahead.first().context("no commits")?; // ahead is youngest first
501 let first_commit = ahead.last().context("no commits")?; 514 let first_commit = ahead.last().context("no commits")?;
515 let push_options_refs: Vec<&str> =
516 git_server_push_options.iter().map(String::as_str).collect();
502 select_servers_push_refs_and_generate_pr_or_pr_update_event( 517 select_servers_push_refs_and_generate_pr_or_pr_update_event(
503 client, 518 client,
504 git_repo, 519 git_repo,
@@ -512,6 +527,7 @@ async fn generate_patches_or_pr_event_or_pr_updates(
512 signer, 527 signer,
513 false, 528 false,
514 term, 529 term,
530 &push_options_refs,
515 ) 531 )
516 .await 532 .await
517 .context(format!( 533 .context(format!(