From d8b85cbce5cba9bfb8b15a8bd5c1b7200ff3e488 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 26 Feb 2026 14:00:12 +0000 Subject: fix: advertise only state events with resolvable git objects git-remote-nostr now walks the per-relay state events captured in FetchReport::state_per_relay (newest first) and advertises the first one whose every OID is either present on at least one git server (confirmed via list_refs) or already available locally. If no such state event exists it falls back to the raw git server state. Previously the latest nostr state event was always used regardless of whether its OIDs had been pushed to any server, causing catastrophic missing-object errors during clone or fetch when a state event was published ahead of the corresponding git push. --- src/bin/git_remote_nostr/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/bin/git_remote_nostr/main.rs') diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index 6186ed3..dad8a99 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -12,7 +12,9 @@ use std::{ }; use anyhow::{Context, Result, bail}; -use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache, is_verbose}; +use client::{ + Connect, FetchReport, consolidate_fetch_reports, get_repo_ref_from_cache, is_verbose, +}; use git::{RepoActions, nostr_url::NostrUrlDecoded}; use ngit::{ client::{self, Params}, @@ -149,7 +151,9 @@ async fn main() -> Result<()> { client.set_signer(signer).await; } - fetching_with_report_for_helper(git_repo_path, &client, &decoded_nostr_url.coordinate).await?; + let fetch_report = + fetching_with_report_for_helper(git_repo_path, &client, &decoded_nostr_url.coordinate) + .await?; let mut repo_ref = get_repo_ref_from_cache(Some(git_repo_path), &decoded_nostr_url.coordinate).await?; @@ -221,10 +225,12 @@ async fn main() -> Result<()> { push_options = PushOptions::default(); } ["list"] => { - list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?); + list_outputs = + Some(list::run_list(&git_repo, &repo_ref, false, &fetch_report).await?); } ["list", "for-push"] => { - list_outputs = Some(list::run_list(&git_repo, &repo_ref, true).await?); + list_outputs = + Some(list::run_list(&git_repo, &repo_ref, true, &fetch_report).await?); } [] => { return Ok(()); @@ -283,7 +289,7 @@ async fn fetching_with_report_for_helper( git_repo_path: &Path, client: &Client, trusted_maintainer_coordinate: &Nip19Coordinate, -) -> Result<()> { +) -> Result { let term = console::Term::stderr(); let verbose = is_verbose(); if verbose { @@ -308,7 +314,7 @@ async fn fetching_with_report_for_helper( } else { term.write_line(&format!("nostr updates: {report}"))?; } - Ok(()) + Ok(report) } #[cfg(test)] -- cgit v1.2.3