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>2026-02-20 12:08:37 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-20 20:43:47 +0000
commit1583a5f5b137ec408d9358c12f6716f7033a2c69 (patch)
tree296498dfbd5c69a5d6dbc95f9255f441a599a1d7 /src/bin/ngit/sub_commands/init.rs
parent7d981ce57797dc772c3b3ced7ba6b61a3acdbed5 (diff)
improve ngit init messaging for co-maintainership acceptance
when a co-maintainer runs ngit init, it now clearly states upfront that they are accepting a co-maintainership offer (not creating a new repo), shows who offered it, and on completion confirms the acceptance and explains they can now push. updating an existing co-maintainer announcement also gets its own clear message.
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
-rw-r--r--src/bin/ngit/sub_commands/init.rs55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 5dd6157..39c8e8e 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -1231,7 +1231,7 @@ fn prompt_git_servers(
1231 } 1231 }
1232} 1232}
1233 1233
1234#[allow(clippy::too_many_lines)] 1234#[allow(clippy::too_many_lines, clippy::too_many_arguments)]
1235async fn publish_and_finalize( 1235async fn publish_and_finalize(
1236 fields: ResolvedFields, 1236 fields: ResolvedFields,
1237 signer: Arc<dyn nostr::prelude::NostrSigner>, 1237 signer: Arc<dyn nostr::prelude::NostrSigner>,
@@ -1240,6 +1240,7 @@ async fn publish_and_finalize(
1240 cli: &Cli, 1240 cli: &Cli,
1241 git_repo: &Repo, 1241 git_repo: &Repo,
1242 repo_config_result: &Result<ngit::repo_ref::RepoConfigYaml>, 1242 repo_config_result: &Result<ngit::repo_ref::RepoConfigYaml>,
1243 is_co_maintainer_first_acceptance: bool,
1243) -> Result<()> { 1244) -> Result<()> {
1244 let git_repo_path = git_repo.get_path()?; 1245 let git_repo_path = git_repo.get_path()?;
1245 1246
@@ -1432,12 +1433,22 @@ async fn publish_and_finalize(
1432 } 1433 }
1433 } 1434 }
1434 1435
1435 // Step 9: Print share URLs 1436 // Step 9: Print share URLs / completion message
1436 let gitworkshop_url = nostr_url_decoded 1437 let gitworkshop_url = nostr_url_decoded
1437 .to_string() 1438 .to_string()
1438 .replace("nostr://", "https://gitworkshop.dev/"); 1439 .replace("nostr://", "https://gitworkshop.dev/");
1439 println!("share your repository: {gitworkshop_url}"); 1440 if is_co_maintainer_first_acceptance {
1440 println!("clone url: {nostr_url}"); 1441 println!("co-maintainership accepted.");
1442 println!("your announcement was published to nostr. you can now push updates.");
1443 println!("your repository URL: {gitworkshop_url}");
1444 println!("your clone URL: {nostr_url}");
1445 println!(
1446 "note: run `ngit init` at any time to update your announcement (relays, git servers, etc.)"
1447 );
1448 } else {
1449 println!("share your repository: {gitworkshop_url}");
1450 println!("clone url: {nostr_url}");
1451 }
1441 1452
1442 // Step 10: Update maintainers.yaml if needed 1453 // Step 10: Update maintainers.yaml if needed
1443 let relays = fields 1454 let relays = fields
@@ -1552,6 +1563,41 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
1552 1563
1553 validate_post_fetch(cli_args, args, &state)?; 1564 validate_post_fetch(cli_args, args, &state)?;
1554 1565
1566 // Print CoMaintainer-specific context before proceeding so the user
1567 // understands they are accepting (or updating) a co-maintainership
1568 // offer, NOT creating a new repository.
1569 let is_co_maintainer_first_acceptance =
1570 if let InitState::CoMaintainer { repo_ref: rr, .. } = &state {
1571 rr.maintainers_without_annoucnement
1572 .as_ref()
1573 .is_some_and(|ms| ms.contains(&user_ref.public_key))
1574 } else {
1575 false
1576 };
1577
1578 if let InitState::CoMaintainer { repo_ref: rr, .. } = &state {
1579 if is_co_maintainer_first_acceptance {
1580 println!(
1581 "accepting co-maintainership of '{}' (offered by {})",
1582 rr.name,
1583 rr.trusted_maintainer
1584 .to_bech32()
1585 .unwrap_or_else(|_| rr.trusted_maintainer.to_string()),
1586 );
1587 println!(
1588 "publishing your repository announcement to nostr to confirm your co-maintainership..."
1589 );
1590 if cli_args.interactive {
1591 println!("tip: run `ngit init -d` to accept with defaults and skip all prompts");
1592 }
1593 } else {
1594 println!(
1595 "updating your co-maintainer announcement for '{}' on nostr...",
1596 rr.name
1597 );
1598 }
1599 }
1600
1555 // Phase 5: Resolve all fields 1601 // Phase 5: Resolve all fields
1556 let repo_config_result = get_repo_config_from_yaml(&git_repo); 1602 let repo_config_result = get_repo_config_from_yaml(&git_repo);
1557 let fields = resolve_fields( 1603 let fields = resolve_fields(
@@ -1575,6 +1621,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
1575 cli_args, 1621 cli_args,
1576 &git_repo, 1622 &git_repo,
1577 &repo_config_result, 1623 &repo_config_result,
1624 is_co_maintainer_first_acceptance,
1578 ) 1625 )
1579 .await 1626 .await
1580} 1627}