Skip to content

Commit

Permalink
rewrite path change patch to work with new API (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored Nov 4, 2024
1 parent 4216d8c commit e9a7598
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/src/ui/add-repository/add-existing-repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit e9a7598

Please sign in to comment.