upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/git_remote_nostr')
-rw-r--r--src/bin/git_remote_nostr/main.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs
index e57dff7..61c439d 100644
--- a/src/bin/git_remote_nostr/main.rs
+++ b/src/bin/git_remote_nostr/main.rs
@@ -30,6 +30,21 @@ struct PushOptions {
30 description: Option<String>, 30 description: Option<String>,
31} 31}
32 32
33impl PushOptions {
34 fn validate(&self) -> Result<Option<(String, String)>> {
35 match (&self.title, &self.description) {
36 (Some(t), Some(d)) => Ok(Some((t.clone(), d.clone()))),
37 (Some(_), None) => bail!(
38 "error: 'title' push-option provided without 'description'. Both title and description are required together, or neither to use defaults."
39 ),
40 (None, Some(_)) => bail!(
41 "error: 'description' push-option provided without 'title'. Both title and description are required together, or neither to use defaults."
42 ),
43 (None, None) => Ok(None),
44 }
45 }
46}
47
33mod fetch; 48mod fetch;
34mod list; 49mod list;
35mod push; 50mod push;
@@ -110,6 +125,7 @@ async fn main() -> Result<()> {
110 fetch::run_fetch(&git_repo, &repo_ref, &stdin, oid, refstr).await?; 125 fetch::run_fetch(&git_repo, &repo_ref, &stdin, oid, refstr).await?;
111 } 126 }
112 ["push", refspec] => { 127 ["push", refspec] => {
128 let title_description = push_options.validate()?;
113 push::run_push( 129 push::run_push(
114 &git_repo, 130 &git_repo,
115 &repo_ref, 131 &repo_ref,
@@ -117,7 +133,7 @@ async fn main() -> Result<()> {
117 refspec, 133 refspec,
118 &client, 134 &client,
119 list_outputs.clone(), 135 list_outputs.clone(),
120 push_options.title.as_ref().zip(push_options.description.as_ref()).map(|(t, d)| (t.clone(), d.clone())), 136 title_description,
121 ) 137 )
122 .await?; 138 .await?;
123 push_options = PushOptions::default(); 139 push_options = PushOptions::default();