fix: check git before get git

This commit is contained in:
tiddlygit-test 2021-05-04 20:04:34 +08:00
parent c9a34b8a8f
commit 2bb6831bae
3 changed files with 6 additions and 5 deletions

View file

@ -106,7 +106,6 @@ export function useWikiWorkspaceForm() {
}, [mainWikiToLink]);
const [gitRepoUrl, gitRepoUrlSetter] = useState<string>('');
// FIXME: on dev, this will get TiddlyGit 's remote repo
useEffect(() => {
void (async function getWorkspaceRemoteEffect(): Promise<void> {
if (existedWikiFolderPath !== undefined) {

View file

@ -47,8 +47,10 @@ export class Git implements IGitService {
public debounceCommitAndSync: (wikiFolderPath: string, remoteUrl: string, userInfo: IGitUserInfos) => Promise<void> | undefined;
public async getWorkspacesRemote(wikiFolderPath: string): Promise<string> {
return await getRemoteUrl(wikiFolderPath);
public async getWorkspacesRemote(wikiFolderPath: string): Promise<string | undefined> {
if (await hasGit(wikiFolderPath)) {
return await getRemoteUrl(wikiFolderPath);
}
}
public async getModifiedFileList(wikiFolderPath: string): Promise<ModifiedFileList[]> {

View file

@ -37,8 +37,8 @@ export interface IGitService {
initWikiGit(wikiFolderPath: string, isSyncedWiki: true, remoteUrl: string, userInfo: IGitUserInfos): Promise<void>;
initWikiGit(wikiFolderPath: string, isSyncedWiki?: false): Promise<void>;
commitAndSync(wikiFolderPath: string, remoteUrl: string, userInfo: IGitUserInfos): Promise<void>;
/** Inspect git's remote url from folder's .git config */
getWorkspacesRemote(wikiFolderPath: string): Promise<string>;
/** Inspect git's remote url from folder's .git config, return undefined if there is no initialized git */
getWorkspacesRemote(wikiFolderPath: string): Promise<string | undefined>;
clone(remoteUrl: string, repoFolderPath: string, userInfo: IGitUserInfos): Promise<void>;
}
export const GitServiceIPCDescriptor = {