Browse Source

fix local cloning

Nostr-Signature: 0e7b4f06276988a2caf1c8fa9f6ba4a1cb683033c0714cc88699e3a4bda67d68 573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc 3c46ff9412a72f3ca39d216d6bd2eee7b9f70331fe8c0d557ee8339be4c05d03fe949e3aaef6e29126d4174b9f6d10de9e605273918106b9d40bc81cfaa1d290
main
Silberengel 3 weeks ago
parent
commit
69efc708d6
  1. 1
      nostr/commit-signatures.jsonl
  2. 12
      src/routes/api/repos/[npub]/[repo]/branches/+server.ts
  3. 5
      src/routes/repos/[npub]/[repo]/+page.svelte

1
nostr/commit-signatures.jsonl

@ -79,3 +79,4 @@ @@ -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"}

12
src/routes/api/repos/[npub]/[repo]/branches/+server.ts

@ -49,11 +49,19 @@ const repoRoot = typeof process !== 'undefined' && process.env?.GIT_REPO_ROOT @@ -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);

5
src/routes/repos/[npub]/[repo]/+page.svelte

@ -1800,8 +1800,9 @@ @@ -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 @@ @@ -5556,7 +5557,7 @@
currentBranch={currentBranch || null}
topics={repoTopics || []}
defaultBranch={defaultBranch || null}
isRepoCloned={isRepoCloned || false}
isRepoCloned={isRepoCloned}
copyingCloneUrl={copyingCloneUrl || false}
onBranchChange={safeHandleBranchChange}
onCopyCloneUrl={safeCopyCloneUrl}

Loading…
Cancel
Save