Ver código fonte

Fixes issue with diff with previous and renames

main
Eric Amodio 6 anos atrás
pai
commit
d11aac0feb
3 arquivos alterados com 29 adições e 8 exclusões
  1. +1
    -0
      CHANGELOG.md
  2. +27
    -4
      src/commands/diffWithPrevious.ts
  3. +1
    -4
      src/system/iterable.ts

+ 1
- 0
CHANGELOG.md Ver arquivo

@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#436](https://github.com/eamodio/vscode-gitlens/issues/436) - Copy to clipboard not working
- Fixes [#442](https://github.com/eamodio/vscode-gitlens/issues/442) - GitLens File History fails if name (or path) starts with -
- Fixes [#440](https://github.com/eamodio/vscode-gitlens/issues/436) - Searching for commits with an empty query yields to no results anymore
- Fixes issue where the *Compare File with Previous Revision* command wouldn't work properly when the file had been renamed in some cases
- Fixes issue where changed files count was wrong when the branch was behind the upstream
- Fixes issue where the *GitLens File History* explorer wasn't being updated automatically for working changes
- Fixes issue where the *Compare File with * Revision* commands in the editor toolbar would show and hide too often because of insignificant focus changes

+ 27
- 4
src/commands/diffWithPrevious.ts Ver arquivo

@ -58,16 +58,39 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
sha = sha + '^';
}
const log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
args.commit = undefined;
let log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
maxCount: 2,
ref: sha,
renames: true
});
if (log === undefined) {
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
if (log !== undefined) {
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
}
else {
// Only kick out if we aren't looking for the previous sha -- since renames won't return a log above
if (sha === undefined || !sha.endsWith('^')) {
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
}
// Check for renames
log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
maxCount: 4,
ref: sha.substring(0, sha.length - 1),
renames: true
});
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
if (log === undefined) {
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
}
args.commit = Iterables.next(Iterables.skip(log.commits.values(), 2));
if (args.commit === undefined) {
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
}
}
// If the sha is missing (i.e. working tree), check the file status
// If file is uncommitted, then treat it as a DiffWithWorking

+ 1
- 4
src/system/iterable.ts Ver arquivo

@ -133,10 +133,7 @@ export namespace Iterables {
return source.next().value;
}
export function* skip<T>(
source: Iterable<T> | IterableIterator<T>,
count: number
): Iterable<T> | IterableIterator<T> {
export function* skip<T>(source: Iterable<T> | IterableIterator<T>, count: number): IterableIterator<T> {
let i = 0;
for (const item of source) {
if (i >= count) yield item;

Carregando…
Cancelar
Salvar