Skip to content

Commit

Permalink
Fixes #295, #318 - any error during repo search kills GitLens
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jun 7, 2018
1 parent bc4a84d commit 6b341c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

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

## [Unreleased]
### Fixed
- 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

## [8.3.4] - 2018-06-06
### Added
- 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))
Expand Down
19 changes: 18 additions & 1 deletion src/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export * from './git/formatters/formatters';
export { getNameFromRemoteResource, RemoteProvider, RemoteResource, RemoteResourceType } from './git/remotes/provider';
export { RemoteProviderFactory } from './git/remotes/factory';

const RepoSearchWarnings = {
doesNotExist: /no such file or directory/i
};

export enum GitRepoSearchBy {
Author = 'author',
ChangedOccurrences = 'changed-occurrences',
Expand Down Expand Up @@ -202,7 +206,20 @@ export class GitService extends Disposable {
return accumulator;
}, Object.create(null) as any);

const paths = await this.repositorySearchCore(folderUri.fsPath, depth, excludes);
let paths;
try {
paths = await this.repositorySearchCore(folderUri.fsPath, depth, excludes);
}
catch (ex) {
if (RepoSearchWarnings.doesNotExist.test(ex.message || '')) {
Logger.log(`Searching for repositories (depth=${depth}) in '${folderUri.fsPath}' FAILED${ex.message ? ` (${ex.message})` : ''}`);
}
else {
Logger.error(ex, `Searching for repositories (depth=${depth}) in '${folderUri.fsPath}' FAILED`);
}

return repositories;
}

for (let p of paths) {
p = path.dirname(p);
Expand Down

0 comments on commit 6b341c5

Please sign in to comment.