Browse Source

Fixes #1699: traps errors from getCommitForFile

main
Eric Amodio 3 years ago
parent
commit
9812bbff1b
2 changed files with 21 additions and 13 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +20
    -13
      src/git/providers/localGitProvider.ts

+ 1
- 0
CHANGELOG.md View File

@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#1745](https://github.com/gitkraken/vscode-gitlens/issues/1745) - autolinks.url encodes hash char
- Fixes [#1572](https://github.com/gitkraken/vscode-gitlens/issues/1572) - Forced regular expression search in changes
- Fixes [#1473](https://github.com/gitkraken/vscode-gitlens/issues/1473) - Support VSCodium in interactive rebase editor
- Fixes [#1699](https://github.com/gitkraken/vscode-gitlens/issues/1699) - Exception has occurred: RangeError [ERR_OUT_OF_RANGE]
- Fixes performance issue with the rich hover on the status bar blame
- Fixes cross repository branch switching via the _Git Command Palette_
- Fixes an issue with TOC entries in the VS Code settings editor

+ 20
- 13
src/git/providers/localGitProvider.ts View File

@ -1176,21 +1176,28 @@ export class LocalGitProvider implements GitProvider, Disposable {
fileName: string,
options: { ref?: string; firstIfNotFound?: boolean; range?: Range; reverse?: boolean } = {},
): Promise<GitLogCommit | undefined> {
const log = await this.getLogForFile(repoPath, fileName, {
limit: 2,
ref: options.ref,
range: options.range,
reverse: options.reverse,
});
if (log == null) return undefined;
const cc = Logger.getCorrelationContext();
const commit = options.ref ? log.commits.get(options.ref) : undefined;
if (commit == null && !options.firstIfNotFound && options.ref) {
// If the ref isn't a valid sha we will never find it, so let it fall through so we return the first
if (GitRevision.isSha(options.ref) || GitRevision.isUncommitted(options.ref)) return undefined;
}
try {
const log = await this.getLogForFile(repoPath, fileName, {
limit: 2,
ref: options.ref,
range: options.range,
reverse: options.reverse,
});
if (log == null) return undefined;
return commit ?? Iterables.first(log.commits.values());
const commit = options.ref ? log.commits.get(options.ref) : undefined;
if (commit == null && !options.firstIfNotFound && options.ref) {
// If the ref isn't a valid sha we will never find it, so let it fall through so we return the first
if (GitRevision.isSha(options.ref) || GitRevision.isUncommitted(options.ref)) return undefined;
}
return commit ?? Iterables.first(log.commits.values());
} catch (ex) {
Logger.error(ex, cc);
return undefined;
}
}
@log()

Loading…
Cancel
Save