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-03-03 13:08:56 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-03-04 12:48:37 +0000
commita55d4150066456084fd18987acf014c18d0da976 (patch)
treeb6df894e60bb4fbc8854a76b8036b8a76922010b /src/bin/ngit/sub_commands/init.rs
parentf91a0d00bafe2af1f6b6828c3de3d3e5d65153c3 (diff)
add nostr.repo-relay-only config to limit publishing to repo relays
Adds a git config key nostr.repo-relay-only that, when set to true, causes nostr events to be sent only to the repository's own relays, skipping the user's personal write relays and default/blaster relays. Useful for repositories that should not broadcast to the maintainer's personal relay set. Set persistently via \`git config nostr.repo-relay-only true\` or in one step with \`ngit init --repo-relay-only\`.
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
-rw-r--r--src/bin/ngit/sub_commands/init.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs
index 021a33e..0554f32 100644
--- a/src/bin/ngit/sub_commands/init.rs
+++ b/src/bin/ngit/sub_commands/init.rs
@@ -430,6 +430,10 @@ pub struct SubCommandArgs {
430 #[clap(long)] 430 #[clap(long)]
431 /// usually root commit but will be more recent commit for forks 431 /// usually root commit but will be more recent commit for forks
432 earliest_unique_commit: Option<String>, 432 earliest_unique_commit: Option<String>,
433 #[clap(long)]
434 /// only publish nostr events to repo relays, not to user or default relays
435 /// (sets nostr.repo-relay-only in local git config)
436 repo_relay_only: bool,
433} 437}
434 438
435impl SubCommandArgs { 439impl SubCommandArgs {
@@ -444,6 +448,7 @@ impl SubCommandArgs {
444 || !self.other_maintainers.is_empty() 448 || !self.other_maintainers.is_empty()
445 || !self.hashtag.is_empty() 449 || !self.hashtag.is_empty()
446 || self.earliest_unique_commit.is_some() 450 || self.earliest_unique_commit.is_some()
451 || self.repo_relay_only
447 } 452 }
448} 453}
449 454
@@ -1266,11 +1271,21 @@ async fn publish_and_finalize(
1266 // Step 5: Publish events 1271 // Step 5: Publish events
1267 client.set_signer(signer).await; 1272 client.set_signer(signer).await;
1268 1273
1274 let repo_relay_only = git_repo
1275 .get_git_config_item("nostr.repo-relay-only", None)
1276 .ok()
1277 .flatten()
1278 .is_some_and(|s| s == "true");
1279
1269 let _ = send_events( 1280 let _ = send_events(
1270 client, 1281 client,
1271 Some(git_repo_path), 1282 Some(git_repo_path),
1272 events, 1283 events,
1273 user_ref.relays.write(), 1284 if repo_relay_only {
1285 vec![]
1286 } else {
1287 user_ref.relays.write()
1288 },
1274 fields.relays.clone(), 1289 fields.relays.clone(),
1275 !cli.disable_cli_spinners, 1290 !cli.disable_cli_spinners,
1276 false, 1291 false,
@@ -1522,7 +1537,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
1522 cli_args.interactive, 1537 cli_args.interactive,
1523 )?; 1538 )?;
1524 1539
1525 // Phase 6: Build and publish 1540 // Phase 6: Persist --repo-relay-only flag to local git config if supplied
1541 if args.repo_relay_only {
1542 git_repo.save_git_config_item("nostr.repo-relay-only", "true", false)?;
1543 }
1544
1545 // Phase 7: Build and publish
1526 publish_and_finalize( 1546 publish_and_finalize(
1527 fields, 1547 fields,
1528 signer, 1548 signer,