diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-25 16:46:02 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-26 15:26:14 +0000 |
| commit | 5c305e922e19e4ac65c6a1473be67145a1c73f2b (patch) | |
| tree | fb03feb94b324297df4b3560af379c6c89b1ed6e /src/bin/ngit | |
| parent | 3017faf6d346fa9328c5979c6e9c6bc471bd3942 (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/ngit')
| -rw-r--r-- | src/bin/ngit/sub_commands/send.rs | 38 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/sync.rs | 1 |
2 files changed, 24 insertions, 15 deletions
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index 325ad89..6b18e84 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs | |||
| @@ -50,6 +50,9 @@ pub struct SubCommandArgs { | |||
| 50 | /// publish as Patches even if they may be > 60kb | 50 | /// publish as Patches even if they may be > 60kb |
| 51 | #[arg(long, action)] | 51 | #[arg(long, action)] |
| 52 | pub(crate) force_patch: bool, | 52 | pub(crate) force_patch: bool, |
| 53 | #[clap(long = "push-option", short = 'o', value_parser, num_args = 0..)] | ||
| 54 | /// git push options to pass to the git server (eg. -o secret-scanning.skip) | ||
| 55 | pub(crate) push_options: Vec<String>, | ||
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | /// Validates send command arguments for non-interactive mode. | 58 | /// Validates send command arguments for non-interactive mode. |
| @@ -351,21 +354,26 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re | |||
| 351 | let events = if as_pr { | 354 | let events = if as_pr { |
| 352 | let tip = commits.last().context("no commits")?; // commits has been reversed to oldest first | 355 | let tip = commits.last().context("no commits")?; // commits has been reversed to oldest first |
| 353 | let first_commit = commits.first().context("no commits")?; | 356 | let first_commit = commits.first().context("no commits")?; |
| 354 | select_servers_push_refs_and_generate_pr_or_pr_update_event( | 357 | { |
| 355 | &client, | 358 | let push_options_refs: Vec<&str> = |
| 356 | &git_repo, | 359 | args.push_options.iter().map(String::as_str).collect(); |
| 357 | &repo_ref, | 360 | select_servers_push_refs_and_generate_pr_or_pr_update_event( |
| 358 | tip, | 361 | &client, |
| 359 | first_commit, | 362 | &git_repo, |
| 360 | git_repo.get_commit_parent(first_commit).ok().as_ref(), | 363 | &repo_ref, |
| 361 | &mut user_ref, | 364 | tip, |
| 362 | root_proposal.as_ref(), | 365 | first_commit, |
| 363 | &cover_letter_title_description, | 366 | git_repo.get_commit_parent(first_commit).ok().as_ref(), |
| 364 | &signer, | 367 | &mut user_ref, |
| 365 | true, | 368 | root_proposal.as_ref(), |
| 366 | &console::Term::stdout(), | 369 | &cover_letter_title_description, |
| 367 | ) | 370 | &signer, |
| 368 | .await? | 371 | true, |
| 372 | &console::Term::stdout(), | ||
| 373 | &push_options_refs, | ||
| 374 | ) | ||
| 375 | .await? | ||
| 376 | } | ||
| 369 | } else { | 377 | } else { |
| 370 | let events = generate_cover_letter_and_patch_events( | 378 | let events = generate_cover_letter_and_patch_events( |
| 371 | cover_letter_title_description.clone(), | 379 | cover_letter_title_description.clone(), |
diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs index daebb1b..b377ab4 100644 --- a/src/bin/ngit/sub_commands/sync.rs +++ b/src/bin/ngit/sub_commands/sync.rs | |||
| @@ -187,6 +187,7 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> { | |||
| 187 | &refspecs, | 187 | &refspecs, |
| 188 | &term, | 188 | &term, |
| 189 | *is_grasp_server || is_grasp_server_clone_url(url), | 189 | *is_grasp_server || is_grasp_server_clone_url(url), |
| 190 | &[], | ||
| 190 | ) { | 191 | ) { |
| 191 | Err(error) => { | 192 | Err(error) => { |
| 192 | term.write_line(&format!( | 193 | term.write_line(&format!( |