feat: make getModifiedFileList async

This commit is contained in:
林一二 2021-08-08 16:00:51 +08:00
parent 4ec209096a
commit f73645a352
2 changed files with 5 additions and 6 deletions

View file

@ -2,7 +2,7 @@
import 'source-map-support/register';
import { expose } from 'threads/worker';
import { Observable } from 'rxjs';
import { clone, commitAndSync, GitStep, ILoggerContext, initGit } from 'git-sync-js';
import { clone, commitAndSync, GitStep, ILoggerContext, initGit, getModifiedFileList, getRemoteUrl } from 'git-sync-js';
import { IGitLogMessage, IGitUserInfos } from './interface';
import { defaultGitInfo } from './defaultGitInfo';
import { WikiChannel } from '@/constants/channels';
@ -81,6 +81,6 @@ function cloneWiki(repoFolderPath: string, remoteUrl: string, userInfo: IGitUser
});
}
const gitWorker = { initWikiGit, commitAndSyncWiki, cloneWiki };
const gitWorker = { initWikiGit, commitAndSyncWiki, cloneWiki, getModifiedFileList, getRemoteUrl };
export type GitWorker = typeof gitWorker;
expose(gitWorker);

View file

@ -5,8 +5,6 @@ import {
AssumeSyncError,
CantSyncGitNotInitializedError,
CantSyncInSpecialGitStateAutoFixFailed,
getModifiedFileList,
getRemoteUrl,
GitPullPushError,
GitStep,
ModifiedFileList,
@ -55,12 +53,13 @@ export class Git implements IGitService {
public async getWorkspacesRemote(wikiFolderPath: string): Promise<string | undefined> {
if (await hasGit(wikiFolderPath)) {
return await getRemoteUrl(wikiFolderPath);
return await this.gitWorker?.getRemoteUrl(wikiFolderPath);
}
}
public async getModifiedFileList(wikiFolderPath: string): Promise<ModifiedFileList[]> {
return await getModifiedFileList(wikiFolderPath);
const list = await this.gitWorker?.getModifiedFileList(wikiFolderPath);
return list ?? [];
}
/**