diff --git a/nostr/commit-signatures.jsonl b/nostr/commit-signatures.jsonl index 75a629f..2a43279 100644 --- a/nostr/commit-signatures.jsonl +++ b/nostr/commit-signatures.jsonl @@ -79,3 +79,4 @@ {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771999453,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","load files from HEAD"]],"content":"Signed commit: load files from HEAD","id":"214fc0597e79b465c0c718a2227de942697409002b6cf5c322c9a6d9b36de333","sig":"713a33e751e0582669e9328bca2ac048585534111984bd6ca938270409f7957178d497c92a981719594e927ca7d301e033306c1d1b261395984b91b2d81762e2"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771999938,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","verify button for cloned repos"]],"content":"Signed commit: verify button for cloned repos","id":"4710ea5de6287e00b5da9a6d7cd6568901e3db45a71476b56dc83ec39b8be73d","sig":"7613ca0847af4eb1fd3f52ef0f59c8f6316ba75605085da8eb0a64ced6fe43897d6af26b84d218155ab61ab8e1b42cbc2a686f2eab9572734fb7d911961d3e85"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1772000347,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","added status to patches\nrenamed chat-relay to project-relay"]],"content":"Signed commit: added status to patches\nrenamed chat-relay to project-relay","id":"3c717ed3935bf95a70a0e9ffbe655728d325f72e8cbeb3d38da37b1b6e1304a2","sig":"952584bfe718362864fdf117bb4c4b042dbea9fe2307bca2f94a9004394bb6fdb3f4f4acd6714bcfdb32453a9d09d24e2c97f512bc1b06e1ba3cd50556f67b6e"} +{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1772002202,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","improving commit signing and verification"]],"content":"Signed commit: improving commit signing and verification","id":"c149ee64445a63b9a471d1866df86d702fe3fead1049a8e3272ea76a25f11094","sig":"f0745d02cb1b2ac012feb5e38cd4917eb9af48338eb13626aedae6ce73025758b2debe6874c5af3a4e252241405fdaa91042a031fa56c4fe0257c978d23babb2"} diff --git a/src/routes/api/repos/[npub]/[repo]/branches/+server.ts b/src/routes/api/repos/[npub]/[repo]/branches/+server.ts index 137e252..97251cf 100644 --- a/src/routes/api/repos/[npub]/[repo]/branches/+server.ts +++ b/src/routes/api/repos/[npub]/[repo]/branches/+server.ts @@ -49,11 +49,19 @@ const repoRoot = typeof process !== 'undefined' && process.env?.GIT_REPO_ROOT : '/repos'; export const GET: RequestHandler = createRepoGetHandler( - async (context: RepoRequestContext) => { + async (context: RepoRequestContext, event: RequestEvent) => { const repoPath = join(repoRoot, context.npub, `${context.repo}.git`); + const skipApiFallback = event.url.searchParams.get('skipApiFallback') === 'true'; - // If repo doesn't exist, try to fetch it on-demand + // If repo doesn't exist, try to fetch it on-demand (unless skipApiFallback is true) if (!existsSync(repoPath)) { + // If skipApiFallback is true, return 404 immediately to indicate repo is not cloned + if (skipApiFallback) { + throw handleNotFoundError( + 'Repository is not cloned locally', + { operation: 'getBranches', npub: context.npub, repo: context.repo } + ); + } try { // Fetch repository announcement (case-insensitive) with caching let allEvents = await fetchRepoAnnouncementsWithCache(nostrClient, context.repoOwnerPubkey, eventCache); diff --git a/src/routes/repos/[npub]/[repo]/+page.svelte b/src/routes/repos/[npub]/[repo]/+page.svelte index 57f0b89..263adb5 100644 --- a/src/routes/repos/[npub]/[repo]/+page.svelte +++ b/src/routes/repos/[npub]/[repo]/+page.svelte @@ -1800,8 +1800,9 @@ checkingCloneStatus = true; try { // Check if repo exists locally by trying to fetch branches + // Use skipApiFallback parameter to ensure we only check local repo, not API fallback // 404 = repo not cloned, 403 = repo exists but access denied (cloned), 200 = cloned and accessible - const url = `/api/repos/${npub}/${repo}/branches`; + const url = `/api/repos/${npub}/${repo}/branches?skipApiFallback=true`; console.log(`[Clone Status] Checking clone status for ${npub}/${repo}...`); const response = await fetch(url, { headers: buildApiHeaders() @@ -5556,7 +5557,7 @@ currentBranch={currentBranch || null} topics={repoTopics || []} defaultBranch={defaultBranch || null} - isRepoCloned={isRepoCloned || false} + isRepoCloned={isRepoCloned} copyingCloneUrl={copyingCloneUrl || false} onBranchChange={safeHandleBranchChange} onCopyCloneUrl={safeCopyCloneUrl}