logger.debug({npub,repoName,totalUrls: cloneUrls.length,sshUrls: cloneUrls.filter(url=>url.startsWith('git@')).length},'No usable clone URLs found for API fetch after conversion');
returnnull;
}
logger.debug({npub,repoName,totalUrls: cloneUrls.length,convertedUrls: convertedUrls.length,originalHttpUrls: cloneUrls.filter(url=>url.startsWith('http')).length,sshUrls: cloneUrls.filter(url=>url.startsWith('git@')).length},'Converted clone URLs for API fetch');
// Prioritize GRASP servers (they use Gitea-compatible API)
// Return data even if some fields are empty (at least we got something)
return{
return{
branches: metadata.branches,
branches: metadata.branches||[],
defaultBranch: metadata.defaultBranch,
defaultBranch: metadata.defaultBranch||'main',
files: metadata.files,
files: metadata.files||[],
commits: metadata.commits
commits: metadata.commits||[]
};
};
}else{
logger.warn({url,npub,repoName,attempt: i+1,total: sortedUrls.length},`[${i+1}/${sortedUrls.length}] fetchRepoMetadata returned null, trying next URL`);
}
}
}catch(err){
}catch(err){
logger.debug({error: err,url,npub,repoName},'API fetch failed for URL, trying next');
logger.debug({npub: context.npub,repo: context.repo,branchCount: apiData.branches.length},'Successfully fetched branches via API fallback');
// Return API data directly without cloning
// Return API data directly without cloning
returnjson(apiData.branches);
returnjson(apiData.branches);
}
}
// API fetch failed - repo is not cloned and API fetch didn't work
// API fetch failed - repo is not cloned and API fetch didn't work
// Return 404 with helpful message suggesting to clone
// Check if we have clone URLs to provide better error message
consthasCloneUrls=cloneUrls.length>0;
logger.warn({npub: context.npub,repo: context.repo,hasCloneUrls,cloneUrlCount: cloneUrls.length},'API fallback failed for branches');
throwhandleNotFoundError(
throwhandleNotFoundError(
'Repository is not cloned locally and could not be fetched via API. Privileged users can clone this repository using the "Clone to Server" button.',
hasCloneUrls
?'Repository is not cloned locally and could not be fetched via API from external clone URLs. Privileged users can clone this repository using the "Clone to Server" button.'
:'Repository is not cloned locally and has no external clone URLs for API fallback. Privileged users can clone this repository using the "Clone to Server" button.',
logger.debug({npub: context.npub,repo: context.repo,cloneUrlCount: cloneUrlsForLogging.length,cloneUrls: cloneUrlsForLogging,path: context.path},'Attempting API fallback for tree');
<span>This repository is displayed in <strong>read-only mode</strong> using data from external clone URLs. To enable editing and full features, clone this repository to the server.</span>
<span>
{#ifhasUnlimitedAccess($userStore.userLevel)}
{#ifapiFallbackAvailable===null}
Checking external clone URLs for read-only access...
{:else}
This repository is displayed in <strong>read-only mode</strong> using data from external clone URLs. To enable editing and full features, clone this repository to the server.