From 64747526c9f6ab43f9dac461d056bb42992573b4 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 20 Feb 2026 20:09:09 +0000 Subject: 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. --- src/bin/git_remote_nostr/main.rs | 2 +- src/bin/git_remote_nostr/push.rs | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/bin/git_remote_nostr') diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index f670b7b..e0821e9 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -203,7 +203,7 @@ async fn main() -> Result<()> { &repo_ref, &stdin, refspec, - &client, + &mut client, list_outputs.clone(), title_description, ) 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::{ }; use git2::{Oid, Repository}; use ngit::{ + accept_maintainership::accept_maintainership_with_defaults, client::{self, get_event_from_cache_by_id}, git::{self, nostr_url::NostrUrlDecoded}, git_events::{ @@ -50,7 +51,7 @@ pub async fn run_push( repo_ref: &RepoRef, stdin: &Stdin, initial_refspec: &str, - client: &Client, + client: &mut Client, list_outputs: Option, bool)>>, title_description: Option<(String, String)>, ) -> Result<()> { @@ -127,7 +128,7 @@ pub async fn run_push( repo_ref, &git_state_refspecs, &proposal_refspecs, - client, + client, // &mut Client existing_state, &term, title_description.as_ref(), @@ -182,7 +183,7 @@ async fn create_and_publish_events_and_proposals( repo_ref: &RepoRef, git_server_refspecs: &Vec, proposal_refspecs: &Vec, - client: &Client, + client: &mut Client, existing_state: HashMap, term: &Term, title_description: Option<&(String, String)>, @@ -216,16 +217,14 @@ async fn create_and_publish_events_and_proposals( .clone() .is_some_and(|ms| ms.contains(&user_ref.public_key)) { - for refspec in git_server_refspecs { - let (_, to) = refspec_to_from_to(refspec).unwrap(); - eprintln!( - "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.", - repo_ref.name, - ); - } - if proposal_refspecs.is_empty() { - return Ok((vec![], true)); - } + // Auto-accept co-maintainership: publish the user's own announcement + // with defaults before proceeding with the push. The announcement is + // required (not just for consent, but to prevent scammers from + // attributing a person's state events to a fake project with the same + // identifier). See docs/design/co-maintainer-announcement-rationale.md. + accept_maintainership_with_defaults(git_repo, repo_ref, &user_ref, client, &signer) + .await + .context("failed to auto-accept co-maintainership")?; } let mut events = vec![]; -- cgit v1.2.3