diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-20 20:09:09 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-20 21:21:48 +0000 |
| commit | 64747526c9f6ab43f9dac461d056bb42992573b4 (patch) | |
| tree | c2506828ae7b188e3e4b569cd73202ec37779278 /src/bin/git_remote_nostr/push.rs | |
| parent | 365dfb9a1e986b68bc2389e2a3cd3da30b0d4636 (diff) | |
extract grasp/maintainership helpers to lib and auto-accept on push
move apply_grasp_infrastructure, latest_event_repo_ref to lib/repo_ref.rs
and wait_for_grasp_servers + grasp_servers_from_user_or_fallback to a
new lib/accept_maintainership.rs so both binaries can share them.
add accept_maintainership_with_defaults which publishes the co-maintainer's
own Kind:30617 announcement with defaults (user grasp servers, shared
metadata from existing events) then waits for grasp server provisioning
and updates nostr.repo config and origin remote.
replace the push error block with a call to accept_maintainership_with_defaults
so pushing now silently accepts co-maintainership instead of failing.
Diffstat (limited to 'src/bin/git_remote_nostr/push.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index e1c94f8..b64cdd9 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -14,6 +14,7 @@ use git_events::{ | |||
| 14 | }; | 14 | }; |
| 15 | use git2::{Oid, Repository}; | 15 | use git2::{Oid, Repository}; |
| 16 | use ngit::{ | 16 | use ngit::{ |
| 17 | accept_maintainership::accept_maintainership_with_defaults, | ||
| 17 | client::{self, get_event_from_cache_by_id}, | 18 | client::{self, get_event_from_cache_by_id}, |
| 18 | git::{self, nostr_url::NostrUrlDecoded}, | 19 | git::{self, nostr_url::NostrUrlDecoded}, |
| 19 | git_events::{ | 20 | git_events::{ |
| @@ -50,7 +51,7 @@ pub async fn run_push( | |||
| 50 | repo_ref: &RepoRef, | 51 | repo_ref: &RepoRef, |
| 51 | stdin: &Stdin, | 52 | stdin: &Stdin, |
| 52 | initial_refspec: &str, | 53 | initial_refspec: &str, |
| 53 | client: &Client, | 54 | client: &mut Client, |
| 54 | list_outputs: Option<HashMap<String, (HashMap<String, String>, bool)>>, | 55 | list_outputs: Option<HashMap<String, (HashMap<String, String>, bool)>>, |
| 55 | title_description: Option<(String, String)>, | 56 | title_description: Option<(String, String)>, |
| 56 | ) -> Result<()> { | 57 | ) -> Result<()> { |
| @@ -127,7 +128,7 @@ pub async fn run_push( | |||
| 127 | repo_ref, | 128 | repo_ref, |
| 128 | &git_state_refspecs, | 129 | &git_state_refspecs, |
| 129 | &proposal_refspecs, | 130 | &proposal_refspecs, |
| 130 | client, | 131 | client, // &mut Client |
| 131 | existing_state, | 132 | existing_state, |
| 132 | &term, | 133 | &term, |
| 133 | title_description.as_ref(), | 134 | title_description.as_ref(), |
| @@ -182,7 +183,7 @@ async fn create_and_publish_events_and_proposals( | |||
| 182 | repo_ref: &RepoRef, | 183 | repo_ref: &RepoRef, |
| 183 | git_server_refspecs: &Vec<String>, | 184 | git_server_refspecs: &Vec<String>, |
| 184 | proposal_refspecs: &Vec<String>, | 185 | proposal_refspecs: &Vec<String>, |
| 185 | client: &Client, | 186 | client: &mut Client, |
| 186 | existing_state: HashMap<String, String>, | 187 | existing_state: HashMap<String, String>, |
| 187 | term: &Term, | 188 | term: &Term, |
| 188 | title_description: Option<&(String, String)>, | 189 | title_description: Option<&(String, String)>, |
| @@ -216,16 +217,14 @@ async fn create_and_publish_events_and_proposals( | |||
| 216 | .clone() | 217 | .clone() |
| 217 | .is_some_and(|ms| ms.contains(&user_ref.public_key)) | 218 | .is_some_and(|ms| ms.contains(&user_ref.public_key)) |
| 218 | { | 219 | { |
| 219 | for refspec in git_server_refspecs { | 220 | // Auto-accept co-maintainership: publish the user's own announcement |
| 220 | let (_, to) = refspec_to_from_to(refspec).unwrap(); | 221 | // with defaults before proceeding with the push. The announcement is |
| 221 | eprintln!( | 222 | // required (not just for consent, but to prevent scammers from |
| 222 | "error {to} you have been offered co-maintainership of '{}'. to accept, run `ngit init` which will publish your own repository announcement. use `ngit init -d` to accept with defaults and no interactive prompts.", | 223 | // attributing a person's state events to a fake project with the same |
| 223 | repo_ref.name, | 224 | // identifier). See docs/design/co-maintainer-announcement-rationale.md. |
| 224 | ); | 225 | accept_maintainership_with_defaults(git_repo, repo_ref, &user_ref, client, &signer) |
| 225 | } | 226 | .await |
| 226 | if proposal_refspecs.is_empty() { | 227 | .context("failed to auto-accept co-maintainership")?; |
| 227 | return Ok((vec![], true)); | ||
| 228 | } | ||
| 229 | } | 228 | } |
| 230 | 229 | ||
| 231 | let mut events = vec![]; | 230 | let mut events = vec![]; |