From 4fe17a12de8d15f7ab9d8690e45dbf809530a3f8 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 30 Oct 2024 11:40:39 -0700 Subject: [PATCH] rewrite path change patch to work with new API --- .../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 5615ddb544..6bfdb9887c 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 () => {