Fix useGitFetch with no remote

This commit is contained in:
Alex Gleason committed 2025-12-25 00:42:15 -06:00
1 parent 5ef848b45e
commit 6a74120ddd
2 files changed
+7 -2

No files matched your search

+6 -2
View File
@@ -7,16 +7,20 @@ interface GitFetchResult {
fetchHeadDescription: string | null;
}
export function useGitFetch(dir: string | undefined) {
export function useGitFetch(dir: string | undefined, remote = 'origin') {
const { git } = useGit();
const query = useQuery({
queryKey: ['git-fetch', dir],
queryFn: async (): Promise<GitFetchResult> => {
if (dir) {
const remotes = await git.listRemotes({ dir });
const hasOrigin = !!remotes.find(r => r.remote === remote);
if (dir && hasOrigin) {
try {
return await git.fetch({
dir,
remote,
});
} catch (error) {
// Fetch failed, but don't throw - just log and return null
+1
View File
@@ -242,6 +242,7 @@ export class Git {
http: this.httpForUrl(remoteUrl),
onAuth: this.onAuth,
...options,
remote,
});
}