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/git_remote_nostr/main.rs | |
| 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/git_remote_nostr/main.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index e0821e9..6186ed3 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs | |||
| @@ -28,6 +28,7 @@ use crate::{client::Client, git::Repo}; | |||
| 28 | struct PushOptions { | 28 | struct PushOptions { |
| 29 | title: Option<String>, | 29 | title: Option<String>, |
| 30 | description: Option<String>, | 30 | description: Option<String>, |
| 31 | git_server_extras: Vec<String>, | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | /// Strip git's c-style quoting from a push-option value. | 34 | /// Strip git's c-style quoting from a push-option value. |
| @@ -118,6 +119,7 @@ mod list; | |||
| 118 | mod push; | 119 | mod push; |
| 119 | 120 | ||
| 120 | #[tokio::main] | 121 | #[tokio::main] |
| 122 | #[allow(clippy::too_many_lines)] | ||
| 121 | async fn main() -> Result<()> { | 123 | async fn main() -> Result<()> { |
| 122 | if std::env::var("NGITTEST").is_ok() { | 124 | if std::env::var("NGITTEST").is_ok() { |
| 123 | std::env::set_var("NGIT_VERBOSE", "1"); | 125 | std::env::set_var("NGIT_VERBOSE", "1"); |
| @@ -177,16 +179,23 @@ async fn main() -> Result<()> { | |||
| 177 | } | 179 | } |
| 178 | ["option", "push-option", rest @ ..] => { | 180 | ["option", "push-option", rest @ ..] => { |
| 179 | let option = strip_git_quoting(&rest.join(" ")); | 181 | let option = strip_git_quoting(&rest.join(" ")); |
| 180 | if let Some((key, value)) = option.split_once('=') { | 182 | let handled_by_ngit = if let Some((key, value)) = option.split_once('=') { |
| 181 | match key { | 183 | match key { |
| 182 | "title" => { | 184 | "title" => { |
| 183 | push_options.title = Some(decode_push_option_escapes(value)); | 185 | push_options.title = Some(decode_push_option_escapes(value)); |
| 186 | true | ||
| 184 | } | 187 | } |
| 185 | "description" => { | 188 | "description" => { |
| 186 | push_options.description = Some(decode_push_option_escapes(value)); | 189 | push_options.description = Some(decode_push_option_escapes(value)); |
| 190 | true | ||
| 187 | } | 191 | } |
| 188 | _ => {} | 192 | _ => false, |
| 189 | } | 193 | } |
| 194 | } else { | ||
| 195 | false | ||
| 196 | }; | ||
| 197 | if !handled_by_ngit { | ||
| 198 | push_options.git_server_extras.push(option); | ||
| 190 | } | 199 | } |
| 191 | println!("ok"); | 200 | println!("ok"); |
| 192 | } | 201 | } |
| @@ -206,6 +215,7 @@ async fn main() -> Result<()> { | |||
| 206 | &mut client, | 215 | &mut client, |
| 207 | list_outputs.clone(), | 216 | list_outputs.clone(), |
| 208 | title_description, | 217 | title_description, |
| 218 | push_options.git_server_extras.clone(), | ||
| 209 | ) | 219 | ) |
| 210 | .await?; | 220 | .await?; |
| 211 | push_options = PushOptions::default(); | 221 | push_options = PushOptions::default(); |