diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-26 14:00:12 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-26 15:26:20 +0000 |
| commit | d8b85cbce5cba9bfb8b15a8bd5c1b7200ff3e488 (patch) | |
| tree | 608d535034e73fe61c5edbf1bbc3c51621f70faa /src/bin/git_remote_nostr/main.rs | |
| parent | b85683201250e97a30bfe7a5dbba5508f8e86f65 (diff) | |
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.
Diffstat (limited to 'src/bin/git_remote_nostr/main.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/main.rs | 18 |
1 files changed, 12 insertions, 6 deletions
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::{ | |||
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | use anyhow::{Context, Result, bail}; | 14 | use anyhow::{Context, Result, bail}; |
| 15 | use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache, is_verbose}; | 15 | use client::{ |
| 16 | Connect, FetchReport, consolidate_fetch_reports, get_repo_ref_from_cache, is_verbose, | ||
| 17 | }; | ||
| 16 | use git::{RepoActions, nostr_url::NostrUrlDecoded}; | 18 | use git::{RepoActions, nostr_url::NostrUrlDecoded}; |
| 17 | use ngit::{ | 19 | use ngit::{ |
| 18 | client::{self, Params}, | 20 | client::{self, Params}, |
| @@ -149,7 +151,9 @@ async fn main() -> Result<()> { | |||
| 149 | client.set_signer(signer).await; | 151 | client.set_signer(signer).await; |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | fetching_with_report_for_helper(git_repo_path, &client, &decoded_nostr_url.coordinate).await?; | 154 | let fetch_report = |
| 155 | fetching_with_report_for_helper(git_repo_path, &client, &decoded_nostr_url.coordinate) | ||
| 156 | .await?; | ||
| 153 | 157 | ||
| 154 | let mut repo_ref = | 158 | let mut repo_ref = |
| 155 | get_repo_ref_from_cache(Some(git_repo_path), &decoded_nostr_url.coordinate).await?; | 159 | get_repo_ref_from_cache(Some(git_repo_path), &decoded_nostr_url.coordinate).await?; |
| @@ -221,10 +225,12 @@ async fn main() -> Result<()> { | |||
| 221 | push_options = PushOptions::default(); | 225 | push_options = PushOptions::default(); |
| 222 | } | 226 | } |
| 223 | ["list"] => { | 227 | ["list"] => { |
| 224 | list_outputs = Some(list::run_list(&git_repo, &repo_ref, false).await?); | 228 | list_outputs = |
| 229 | Some(list::run_list(&git_repo, &repo_ref, false, &fetch_report).await?); | ||
| 225 | } | 230 | } |
| 226 | ["list", "for-push"] => { | 231 | ["list", "for-push"] => { |
| 227 | list_outputs = Some(list::run_list(&git_repo, &repo_ref, true).await?); | 232 | list_outputs = |
| 233 | Some(list::run_list(&git_repo, &repo_ref, true, &fetch_report).await?); | ||
| 228 | } | 234 | } |
| 229 | [] => { | 235 | [] => { |
| 230 | return Ok(()); | 236 | return Ok(()); |
| @@ -283,7 +289,7 @@ async fn fetching_with_report_for_helper( | |||
| 283 | git_repo_path: &Path, | 289 | git_repo_path: &Path, |
| 284 | client: &Client, | 290 | client: &Client, |
| 285 | trusted_maintainer_coordinate: &Nip19Coordinate, | 291 | trusted_maintainer_coordinate: &Nip19Coordinate, |
| 286 | ) -> Result<()> { | 292 | ) -> Result<FetchReport> { |
| 287 | let term = console::Term::stderr(); | 293 | let term = console::Term::stderr(); |
| 288 | let verbose = is_verbose(); | 294 | let verbose = is_verbose(); |
| 289 | if verbose { | 295 | if verbose { |
| @@ -308,7 +314,7 @@ async fn fetching_with_report_for_helper( | |||
| 308 | } else { | 314 | } else { |
| 309 | term.write_line(&format!("nostr updates: {report}"))?; | 315 | term.write_line(&format!("nostr updates: {report}"))?; |
| 310 | } | 316 | } |
| 311 | Ok(()) | 317 | Ok(report) |
| 312 | } | 318 | } |
| 313 | 319 | ||
| 314 | #[cfg(test)] | 320 | #[cfg(test)] |