Add Local Repository keeps showing the not-a-Git-repository warning after the path is corrected
- Dominant language
- TypeScript
- Stars
- 21.8k
- Forks
- 10.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 25
Description
### The problem
In **Add Local Repository**, the "This directory does not appear to be a Git repository" warning doesn't clear when you correct the path. Once it has appeared, it stays on screen for whatever you type next, including a perfectly valid repository, until you submit again.
While it's showing, it also offers:
> Would you like to **create a repository** here instead?
which is being offered for a directory that already is a Git repository.
The path field itself is fine — clicking **Add Repository** re-validates and adds the repository normally. It's only the warning that's out of date, but it's fairly convincing while it's up.
### Release version
3.6.3
### Operating system
macOS 26.5.2 (arm64)
### Steps to reproduce the behavior
1. **File → Add Local Repository**.
2. Enter a path that isn't a Git repository, e.g. `~/Documents`.
3. Click **Add Repository**. The warning appears, as it should.
4. Without closing the dialog, change the path to a valid repository.
5. The warning is still there, and still offering to create a repository at a path that already has one.
6. Clicking **Add Repository** works — the repository is added and the warning goes away.
### Log files
No response
### Screenshots
No response
### Additional context
The validation only ever runs on submit. `onPathChanged` calls `updatePath`, which just stores the path:
```ts
private onPathChanged = async (path: string) => {
if (this.state.path !== path) {
this.updatePath(path)
}
}
private async updatePath(path: string) {
this.setState({ path })
}
```
`validatePath` is only reached from `addRepository` and `onTrustDirectory`, and there's no `componentDidUpdate` or debounce doing it in the background, so `showNonGitRepositoryWarning` keeps whatever value the last submit left it with.
Worth noting `validatePath` already guards against races when it does run:
```ts
this.setState(state => (path === state.path ? { ...result } : null))
```
so re-validating as the path changes looks safe to add — a debounced call from `onPathChanged` would do it. Failing that, clearing `showNonGitRepositoryWarning` (and the bare/unsafe flags) whenever the path changes would at least stop the dialog stating something it no longer knows to be true.
Happy to open a PR for this if you'd like it — just say which approach you'd prefer.
Contributor guide
Research direction
Start at the Add Local Repository flow and read onPathChanged, updatePath, validatePath, addRepository, and onTrustDirectory. Reproduce the warning with an invalid path, then change to a valid Git repository without submitting. Done means the stale warning and create-repository offer no longer appear for the corrected path, while Add Repository still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, typescript
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100