diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-05-31 15:34:21 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-05-31 19:50:06 +0100 |
| commit | 5f45edbebe310decb06f955d95665a6ad387c6cb (patch) | |
| tree | d6da1d3148e55aa75fc28dca22ad70aa2a5fd224 /src/bin | |
| parent | 6f74dd518fbb74dfd2abbe2e1c5bb5df7a7d0562 (diff) | |
feat(push): prevent push if no ann event
To ensure additional maintainers publish an annoucement event,
require it for them to push
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 14 | ||||
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index c4953f8..56bf177 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -199,6 +199,20 @@ async fn create_and_publish_events( | |||
| 199 | if proposal_refspecs.is_empty() { | 199 | if proposal_refspecs.is_empty() { |
| 200 | return Ok((vec![], true)); | 200 | return Ok((vec![], true)); |
| 201 | } | 201 | } |
| 202 | } else if repo_ref | ||
| 203 | .maintainers_without_annoucnement | ||
| 204 | .clone() | ||
| 205 | .is_some_and(|ms| ms.contains(&user_ref.public_key)) | ||
| 206 | { | ||
| 207 | for refspec in git_server_refspecs { | ||
| 208 | let (_, to) = refspec_to_from_to(refspec).unwrap(); | ||
| 209 | eprintln!( | ||
| 210 | "error {to} you must run `ngit init` before pushing updates. you've been offered maintainership but you must accept it before pushing", | ||
| 211 | ); | ||
| 212 | } | ||
| 213 | if proposal_refspecs.is_empty() { | ||
| 214 | return Ok((vec![], true)); | ||
| 215 | } | ||
| 202 | } | 216 | } |
| 203 | 217 | ||
| 204 | let mut events = vec![]; | 218 | let mut events = vec![]; |
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 1d9fda0..aea4f8b 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -703,6 +703,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 703 | relays: relays.clone(), | 703 | relays: relays.clone(), |
| 704 | blossoms, | 704 | blossoms, |
| 705 | trusted_maintainer: user_ref.public_key, | 705 | trusted_maintainer: user_ref.public_key, |
| 706 | maintainers_without_annoucnement: None, | ||
| 706 | maintainers: maintainers.clone(), | 707 | maintainers: maintainers.clone(), |
| 707 | events: HashMap::new(), | 708 | events: HashMap::new(), |
| 708 | nostr_git_url: None, | 709 | nostr_git_url: None, |