diff --git a/src/hooks/useGitFetch.ts b/src/hooks/useGitFetch.ts index 529a4e9d..bceb7114 100644 --- a/src/hooks/useGitFetch.ts +++ b/src/hooks/useGitFetch.ts @@ -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 => { - 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 diff --git a/src/lib/git.ts b/src/lib/git.ts index 4fa55118..184a2555 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -242,6 +242,7 @@ export class Git { http: this.httpForUrl(remoteUrl), onAuth: this.onAuth, ...options, + remote, }); }