From d8e46732b3aa51fcb3b3e83aab29f87b8b85c8d3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 28 Dec 2025 23:38:22 -0600 Subject: [PATCH] Nostr git improve error reporting for push --- .../git-sync/steps/SyncStepError.tsx | 4 +++- src/lib/git.ts | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/git-sync/steps/SyncStepError.tsx b/src/components/git-sync/steps/SyncStepError.tsx index 1fd27d04..539ce3c6 100644 --- a/src/components/git-sync/steps/SyncStepError.tsx +++ b/src/components/git-sync/steps/SyncStepError.tsx @@ -157,7 +157,9 @@ export function SyncStepError({ error, onDismiss, onForcePull, onForcePush, onPu return (
- {error.message} + + {error.message} + {renderDismissButton()}
diff --git a/src/lib/git.ts b/src/lib/git.ts index 3212c1da..597808fc 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -885,7 +885,15 @@ export class Git { throw new Error('Repository not found on Nostr network'); } - const cloneUrls = repo.tags.find(([name]) => name === 'clone')?.slice(1) ?? []; + const cloneUrls = (repo.tags.find(([name]) => name === 'clone')?.slice(1) ?? []) + .map((url) => { + try { + return new URL(url); + } catch { + return null; + } + }) + .filter((url): url is URL => url !== null); if (cloneUrls.length === 0) { throw new Error('No clone URLs found in repository announcement'); @@ -980,9 +988,9 @@ export class Git { git.push({ ...options, fs: this.fs, - http: this.httpForUrl(url), + http: this.httpForUrl(url.href), onAuth: this.onAuth, - url, + url: url.href, dir, }), ]) @@ -999,9 +1007,9 @@ export class Git { if (result.status === 'rejected') { const error = result.reason; const errorMessage = error instanceof Error ? error.message : String(error); - return ` - ${url}: ${errorMessage}`; + return ` - ${url.host}: ${errorMessage}`; } - return ` - ${url}: Unknown error`; + return ` - ${url.host}: Unknown error`; }).join('\n'); throw new Error(`Failed to push to any clone URLs:\n${errorDetails}`);