From e91f95f0d4577d64e41e3ac1d7ae87035a5f12e0 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 18 Sep 2024 12:13:26 +0100 Subject: fix(remote): create pr commit error reporting so it clear which patch is causing issues and it continues to report the fetch problem to the git client. we need a better solution it degrades gracefully rather than stopping the operation. perhaps list needs to only list PRs which it can create from existing data objects? perhaps list also needs fetch objects before fetch is called? --- src/bin/git_remote_nostr/fetch.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index 5dd6ce8..2e16297 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -18,6 +18,8 @@ use ngit::{ login::get_curent_user, repo_ref::RepoRef, }; +use nostr::nips::nip19; +use nostr_sdk::ToBech32; use crate::utils::{ count_lines_per_msg_vec, fetch_or_list_error_is_not_authentication_failure, @@ -93,7 +95,23 @@ pub async fn run_fetch( "parent-commit", )?)? { for patch in &patches_ancestor_first { - git_repo.create_commit_from_patch(patch)?; + if let Err(error) = git_repo.create_commit_from_patch(patch) { + term.write_line( + format!( + "WARNING: cannot create branch for {refstr}, error: {error} for patch {}", + nip19::Nip19Event { + event_id: patch.id(), + author: Some(patch.author()), + kind: Some(patch.kind()), + relays: if let Some(relay) = repo_ref.relays.first() { + vec![relay.to_string()] + } else { vec![]}, + }.to_bech32().unwrap_or_default() + ) + .as_str(), + )?; + break; + } } } else { term.write_line( -- cgit v1.2.3