From e9a759800b9f040289e5a7b6aa12d279e5728d37 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 4 Nov 2024 09:52:42 -0400 Subject: [PATCH] rewrite path change patch to work with new API (#1152) --- .../add-repository/add-existing-repository.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/ui/add-repository/add-existing-repository.tsx b/app/src/ui/add-repository/add-existing-repository.tsx index 5615ddb5443..6bfdb9887ce 100644 --- a/app/src/ui/add-repository/add-existing-repository.tsx +++ b/app/src/ui/add-repository/add-existing-repository.tsx @@ -16,7 +16,6 @@ import { showOpenDialog } from '../main-process-proxy' import { Ref } from '../lib/ref' import { InputError } from '../lib/input-description/input-error' import { IAccessibleMessage } from '../../models/accessible-message' -import { isGitRepository } from './create-repository' interface IAddExistingRepositoryProps { readonly dispatcher: Dispatcher @@ -254,9 +253,21 @@ export class AddExistingRepository extends React.Component< } private onPathChanged = async (path: string) => { - const isRepository = await isGitRepository(this.resolvedPath(path)) + const type = await getRepositoryType(this.resolvedPath(path)) - this.setState({ path, isRepository }) + const isRepository = type.kind !== 'missing' && type.kind !== 'unsafe' + const isRepositoryUnsafe = type.kind === 'unsafe' + const isRepositoryBare = type.kind === 'bare' + const showNonGitRepositoryWarning = !isRepository || isRepositoryBare + const repositoryUnsafePath = type.kind === 'unsafe' ? type.path : undefined + + this.setState({ + path, + isRepositoryUnsafe, + isRepositoryBare, + showNonGitRepositoryWarning, + repositoryUnsafePath, + }) } private showFilePicker = async () => {