upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/init.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-05-21 16:43:32 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-05-21 16:51:57 +0100
commit7490681024f1f21c6c32969ac2901860ebe41883 (patch)
treeef5f02083cdf2f1126d5bdb95f7e7ce7f835fb3e /src/bin/ngit/sub_commands/init.rs
parenta9dc4da2329019f095e811c3837f329ecd94765b (diff)
feat(init): dont ask about state unless needed
reduce the scenarios where we confuse users about state
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
-rw-r--r--src/bin/ngit/sub_commands/init.rs45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index ee5f1ab..53d7552 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -159,7 +159,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
159 }; 159 };
160 160
161 let maintainers: Vec<PublicKey> = { 161 let maintainers: Vec<PublicKey> = {
162 let mut dont_ask = !args.other_maintainers.is_empty(); 162 let mut dont_ask_for_maintainers = !args.other_maintainers.is_empty();
163 let mut maintainers_string = if !args.other_maintainers.is_empty() { 163 let mut maintainers_string = if !args.other_maintainers.is_empty() {
164 [args.other_maintainers.clone()].concat().join(" ") 164 [args.other_maintainers.clone()].concat().join(" ")
165 } else if repo_ref.is_none() && repo_config_result.is_err() { 165 } else if repo_ref.is_none() && repo_config_result.is_err() {
@@ -194,37 +194,48 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
194 } 194 }
195 }; 195 };
196 'outer: loop { 196 'outer: loop {
197 if !dont_ask && user_ref.public_key.to_bech32()?.eq(&maintainers_string) { 197 if !dont_ask_for_maintainers && user_ref.public_key.to_bech32()?.eq(&maintainers_string)
198 {
198 if Interactor::default().confirm( 199 if Interactor::default().confirm(
199 PromptConfirmParms::default() 200 PromptConfirmParms::default()
200 .with_prompt("are you the only maintainer?") 201 .with_prompt("are you the only maintainer?")
201 .with_default(true), 202 .with_default(true),
202 )? { 203 )? {
203 dont_ask = true; 204 dont_ask_for_maintainers = true;
204 } else { 205 } else {
205 let mut opt_out_default = false; 206 let mut ask_about_state = false;
206 if !Interactor::default().confirm( 207 if !Interactor::default().confirm(
207 PromptConfirmParms::default() 208 PromptConfirmParms::default()
208 .with_prompt("are the other maintainers on nostr?") 209 .with_prompt("are the other maintainers on nostr?")
209 .with_default(true), 210 .with_default(true),
210 )? { 211 )? {
211 opt_out_default = true; 212 dont_ask_for_maintainers = true;
212 dont_ask = true; 213 ask_about_state = true;
213 } 214 } else if !Interactor::default().confirm(
214 println!(
215 "nostr can reduce the trust placed in git servers by storing the state of git branches and tags. if you have other maintainers not using git via nostr, the verifiable state can fall behind the git server."
216 );
217
218 if Interactor::default().confirm(
219 PromptConfirmParms::default() 215 PromptConfirmParms::default()
220 .with_prompt("opt-out of storing git state on nostr and relay on git server for now? you will still receive PRs and issues via nostr") 216 .with_prompt(
217 "are you going to ask them to use ngit with this repository?",
218 )
221 .with_default(true), 219 .with_default(true),
222 )? { 220 )? {
223 git_repo.save_git_config_item("nostr.nostate", "true", opt_out_default)?; 221 ask_about_state = true;
222 }
223
224 if ask_about_state {
225 println!(
226 "nostr can reduce the trust placed in git servers by storing the state of git branches and tags. You can also use nostr-permissioned git servers. If you have other maintainers not using git via nostr, the verifiable state can fall behind the git server."
227 );
228 if Interactor::default().confirm(
229 PromptConfirmParms::default()
230 .with_prompt("opt-out of storing git state on nostr and relay on git server for now? you will still receive PRs and issues via nostr")
231 .with_default(true),
232 )? {
233 git_repo.save_git_config_item("nostr.nostate", "true", false)?;
234 }
224 } 235 }
225 } 236 }
226 } 237 }
227 if !dont_ask { 238 if !dont_ask_for_maintainers {
228 println!("{}", &maintainers_string); 239 println!("{}", &maintainers_string);
229 maintainers_string = Interactor::default().input( 240 maintainers_string = Interactor::default().input(
230 PromptInputParms::default() 241 PromptInputParms::default()
@@ -238,7 +249,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
238 maintainers.push(m_pubkey); 249 maintainers.push(m_pubkey);
239 } else { 250 } else {
240 println!("not a valid set of space seperated npubs"); 251 println!("not a valid set of space seperated npubs");
241 dont_ask = false; 252 dont_ask_for_maintainers = false;
242 continue 'outer; 253 continue 'outer;
243 } 254 }
244 } 255 }
@@ -258,7 +269,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
258 }; 269 };
259 if no_state { 270 if no_state {
260 println!( 271 println!(
261 "you have opted out of storing git state on nostr, so a git server must be used for the state of authoritative branches, tags and related git objects." 272 "you have opted out of storing git state on nostr, so a git server must be used for the state of authoritative branches, tags and related git objects. you can run `ngit init` again to change this later."
262 ); 273 );
263 } else { 274 } else {
264 println!( 275 println!(