upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-02-23 14:23:26 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-02-23 14:23:26 +0000
commitd3bf05365ff2d360d53abe2324f42d98f0c1779c (patch)
treec409f9d98e0cc6deb49489a98d3a55c4fc20722b
parentd5284b758661c491e6a206570763f2982424b70a (diff)
feat(init): improve copy order
move instruction to commit and push maintainers.yaml to end of file
-rw-r--r--src/sub_commands/init.rs47
-rw-r--r--tests/init.rs13
2 files changed, 33 insertions, 27 deletions
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs
index 54b6156..4f098c0 100644
--- a/src/sub_commands/init.rs
+++ b/src/sub_commands/init.rs
@@ -279,28 +279,6 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
279 } 279 }
280 }; 280 };
281 281
282 // if yaml file doesnt exist or needs updating
283 if match &repo_config_result {
284 Ok(config) => {
285 !(extract_pks(config.maintainers.clone())?.eq(&maintainers)
286 && config.relays.eq(&relays))
287 }
288 Err(_) => true,
289 } {
290 save_repo_config_to_yaml(&git_repo, maintainers.clone(), relays.clone())?;
291 println!(
292 "maintainers.yaml {}. commit and push.",
293 if repo_config_result.is_err() {
294 "created"
295 } else {
296 "updated"
297 }
298 );
299 println!(
300 "this enables existing contributors to automatically fetch your repo event (instead of one from a pubkey pretending to be the maintainer)"
301 );
302 }
303
304 println!("publishing repostory reference..."); 282 println!("publishing repostory reference...");
305 283
306 let repo_event = RepoRef { 284 let repo_event = RepoRef {
@@ -311,7 +289,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
311 git_server, 289 git_server,
312 web, 290 web,
313 relays: relays.clone(), 291 relays: relays.clone(),
314 maintainers, 292 maintainers: maintainers.clone(),
315 } 293 }
316 .to_event(&keys)?; 294 .to_event(&keys)?;
317 295
@@ -319,10 +297,31 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
319 &client, 297 &client,
320 vec![repo_event], 298 vec![repo_event],
321 user_ref.relays.write(), 299 user_ref.relays.write(),
322 relays, 300 relays.clone(),
323 !cli_args.disable_cli_spinners, 301 !cli_args.disable_cli_spinners,
324 ) 302 )
325 .await?; 303 .await?;
326 304
305 // if yaml file doesnt exist or needs updating
306 if match &repo_config_result {
307 Ok(config) => {
308 !(extract_pks(config.maintainers.clone())?.eq(&maintainers)
309 && config.relays.eq(&relays))
310 }
311 Err(_) => true,
312 } {
313 save_repo_config_to_yaml(&git_repo, maintainers.clone(), relays.clone())?;
314 println!(
315 "maintainers.yaml {}. commit and push.",
316 if repo_config_result.is_err() {
317 "created"
318 } else {
319 "updated"
320 }
321 );
322 println!(
323 "this optional file enables existing contributors to automatically fetch your repo event (instead of one from a pubkey pretending to be the maintainer)"
324 );
325 }
327 Ok(()) 326 Ok(())
328} 327}
diff --git a/tests/init.rs b/tests/init.rs
index d733643..7c69784 100644
--- a/tests/init.rs
+++ b/tests/init.rs
@@ -7,12 +7,18 @@ fn expect_msgs_first(p: &mut CliTester) -> Result<()> {
7 p.expect("\r")?; 7 p.expect("\r")?;
8 p.expect("logged in as fred\r\n")?; 8 p.expect("logged in as fred\r\n")?;
9 // // p.expect("searching for existing claims on repository...\r\n")?; 9 // // p.expect("searching for existing claims on repository...\r\n")?;
10 p.expect("maintainers.yaml created. commit and push.\r\n")?;
11 p.expect("this enables existing contributors to automatically fetch your repo event (instead of one from a pubkey pretending to be the maintainer) publishing repostory reference...\r\n")?;
12 p.expect("publishing repostory reference...\r\n")?; 10 p.expect("publishing repostory reference...\r\n")?;
13 Ok(()) 11 Ok(())
14} 12}
15 13
14fn expect_msgs_after(p: &mut CliTester) -> Result<()> {
15 p.expect_after_whitespace("maintainers.yaml created. commit and push.\r\n")?;
16 p.expect(
17 "this optional file enables existing contributors to automatically fetch your repo event (instead of one from a pubkey pretending to be the maintainer)\r\n",
18 )?;
19 Ok(())
20}
21
16fn get_cli_args() -> Vec<&'static str> { 22fn get_cli_args() -> Vec<&'static str> {
17 vec![ 23 vec![
18 "--nsec", 24 "--nsec",
@@ -478,7 +484,8 @@ mod when_repo_not_previously_claimed {
478 ], 484 ],
479 1, 485 1,
480 )?; 486 )?;
481 p.expect_end_with_whitespace()?; 487 expect_msgs_after(&mut p)?;
488 p.expect_end()?;
482 for p in [51, 52, 53, 55, 56, 57] { 489 for p in [51, 52, 53, 55, 56, 57] {
483 relay::shutdown_relay(8000 + p)?; 490 relay::shutdown_relay(8000 + p)?;
484 } 491 }