mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix useGitFetch with no remote
This commit is contained in:
2 files changed
+7
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -242,6 +242,7 @@ export class Git {
|
||||
http: this.httpForUrl(remoteUrl),
|
||||
onAuth: this.onAuth,
|
||||
...options,
|
||||
remote,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user