Skip to content

Commit 6b341c5

Browse files
committed
Fixes #295, #318 - any error during repo search kills GitLens
1 parent bc4a84d commit 6b341c5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
### Fixed
9+
- Fixes more instances of [#295](https://github.com/eamodio/vscode-gitlens/issues/295), [#318](https://github.com/eamodio/vscode-gitlens/issues/318) - Any error encountered during the search for repositories could cause GitLens to die
10+
711
## [8.3.4] - 2018-06-06
812
### Added
913
- Adds clipboard support for Linux without requiring any external dependencies — thanks to [PR #394](https://github.com/eamodio/vscode-gitlens/pull/394) by Cédric Malard ([@cmalard](https://github.com/cmalard))

src/gitService.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export * from './git/formatters/formatters';
1818
export { getNameFromRemoteResource, RemoteProvider, RemoteResource, RemoteResourceType } from './git/remotes/provider';
1919
export { RemoteProviderFactory } from './git/remotes/factory';
2020

21+
const RepoSearchWarnings = {
22+
doesNotExist: /no such file or directory/i
23+
};
24+
2125
export enum GitRepoSearchBy {
2226
Author = 'author',
2327
ChangedOccurrences = 'changed-occurrences',
@@ -202,7 +206,20 @@ export class GitService extends Disposable {
202206
return accumulator;
203207
}, Object.create(null) as any);
204208

205-
const paths = await this.repositorySearchCore(folderUri.fsPath, depth, excludes);
209+
let paths;
210+
try {
211+
paths = await this.repositorySearchCore(folderUri.fsPath, depth, excludes);
212+
}
213+
catch (ex) {
214+
if (RepoSearchWarnings.doesNotExist.test(ex.message || '')) {
215+
Logger.log(`Searching for repositories (depth=${depth}) in '${folderUri.fsPath}' FAILED${ex.message ? ` (${ex.message})` : ''}`);
216+
}
217+
else {
218+
Logger.error(ex, `Searching for repositories (depth=${depth}) in '${folderUri.fsPath}' FAILED`);
219+
}
220+
221+
return repositories;
222+
}
206223

207224
for (let p of paths) {
208225
p = path.dirname(p);

0 commit comments

Comments
 (0)