From f73645a352d850afb7820fb07e8d81437b8ee29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=80=E4=BA=8C?= Date: Sun, 8 Aug 2021 16:00:51 +0800 Subject: [PATCH] feat: make getModifiedFileList async --- src/services/git/gitWorker.ts | 4 ++-- src/services/git/index.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/services/git/gitWorker.ts b/src/services/git/gitWorker.ts index 433643fe..9f4c9c50 100644 --- a/src/services/git/gitWorker.ts +++ b/src/services/git/gitWorker.ts @@ -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); diff --git a/src/services/git/index.ts b/src/services/git/index.ts index cf6b5ac4..06dbbeb6 100644 --- a/src/services/git/index.ts +++ b/src/services/git/index.ts @@ -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 { if (await hasGit(wikiFolderPath)) { - return await getRemoteUrl(wikiFolderPath); + return await this.gitWorker?.getRemoteUrl(wikiFolderPath); } } public async getModifiedFileList(wikiFolderPath: string): Promise { - return await getModifiedFileList(wikiFolderPath); + const list = await this.gitWorker?.getModifiedFileList(wikiFolderPath); + return list ?? []; } /**