Quellcode durchsuchen

Adds support for ranged quick file history

Fixes ranged diffWithPrevious command execution via CodeLens
main
Eric Amodio vor 7 Jahren
Ursprung
Commit
b51d25829b
5 geänderte Dateien mit 33 neuen und 16 gelöschten Zeilen
  1. +4
    -4
      src/commands/showQuickFileHistory.ts
  2. +22
    -5
      src/git/enrichers/logParserEnricher.ts
  3. +1
    -1
      src/gitCodeLensProvider.ts
  4. +2
    -2
      src/quickPicks/commitFileDetails.ts
  5. +4
    -4
      src/quickPicks/fileHistory.ts

+ 4
- 4
src/commands/showQuickFileHistory.ts Datei anzeigen

@ -1,5 +1,5 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { GitService, GitUri, IGitLog } from '../gitService';
import { Logger } from '../logger';
@ -12,7 +12,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
super(Commands.ShowQuickFileHistory);
}
async execute(editor: TextEditor, uri?: Uri, maxCount?: number, goBackCommand?: CommandQuickPickItem, log?: IGitLog, nextPageCommand?: CommandQuickPickItem) {
async execute(editor: TextEditor, uri?: Uri, range?: Range, maxCount?: number, goBackCommand?: CommandQuickPickItem, log?: IGitLog, nextPageCommand?: CommandQuickPickItem) {
if (!(uri instanceof Uri)) {
uri = editor && editor.document && editor.document.uri;
}
@ -28,7 +28,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
const progressCancellation = FileHistoryQuickPick.showProgress(gitUri);
try {
if (!log) {
log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, undefined, maxCount);
log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, range, maxCount);
if (!log) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
}
@ -45,7 +45,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
new CommandQuickPickItem({
label: `go back \u21A9`,
description: `\u00a0 \u2014 \u00a0\u00a0 to history of \u00a0$(file-text) ${path.basename(pick.commit.fileName)}`
}, Commands.ShowQuickFileHistory, [uri, maxCount, goBackCommand, log]),
}, Commands.ShowQuickFileHistory, [uri, undefined, maxCount, goBackCommand, log]),
{ showFileHistory: false },
log);
}

+ 22
- 5
src/git/enrichers/logParserEnricher.ts Datei anzeigen

@ -24,8 +24,6 @@ interface ILogEntry {
summary?: string;
}
const shaRegex = /^[a-f0-9]{40}$/;
export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
private _parseEntries(data: string, isRepoPath: boolean): ILogEntry[] {
@ -45,7 +43,8 @@ export class GitLogParserEnricher implements IGitEnricher {
}
if (!entry) {
if (!shaRegex.test(lineParts[0])) continue;
if (!Git.ShaRegex.test(lineParts[0])) continue;
entry = {
sha: lineParts[0]
};
@ -87,13 +86,28 @@ export class GitLogParserEnricher implements IGitEnricher {
case 'filename':
if (isRepoPath) {
position++;
let diff = false;
while (++position < lines.length) {
lineParts = lines[position].split(' ');
if (/^[a-f0-9]{40}$/.test(lineParts[0])) {
if (Git.ShaRegex.test(lineParts[0])) {
position--;
break;
}
if (diff) continue;
if (lineParts[0] === 'diff') {
diff = true;
entry.fileName = lineParts[2].substring(2);
const originalFileName = lineParts[3].substring(2);
if (entry.fileName !== originalFileName) {
entry.originalFileName = originalFileName;
}
continue;
}
if (entry.fileStatuses == null) {
entry.fileStatuses = [];
}
@ -118,7 +132,10 @@ export class GitLogParserEnricher implements IGitEnricher {
entry.fileStatuses.push(status);
}
entry.fileName = entry.fileStatuses.filter(_ => !!_.fileName).map(_ => _.fileName).join(', ');
if (entry.fileStatuses) {
entry.fileName = entry.fileStatuses.filter(_ => !!_.fileName).map(_ => _.fileName).join(', ');
}
}
else {
position += 2;

+ 1
- 1
src/gitCodeLensProvider.ts Datei anzeigen

@ -384,7 +384,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
lens.command = {
title: title,
command: CodeLensCommand.ShowQuickFileHistory,
arguments: [Uri.file(lens.uri.fsPath)]
arguments: [Uri.file(lens.uri.fsPath), lens.isFullRange ? undefined : lens.blameRange]
};
return lens;
}

+ 2
- 2
src/quickPicks/commitFileDetails.ts Datei anzeigen

@ -81,13 +81,13 @@ export class CommitFileDetailsQuickPick {
items.push(new CommandQuickPickItem({
label: `$(history) Show File History`,
description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(commit.fileName)}`
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand, fileLog]));
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, undefined, currentCommand, fileLog]));
}
items.push(new CommandQuickPickItem({
label: `$(history) Show ${workingFileName && options.showFileHistory ? 'Previous ' : ''}File History`,
description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(commit.fileName)} \u00a0\u2022\u00a0 starting from \u00a0$(git-commit) ${commit.shortSha}`
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand]));
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, undefined, currentCommand]));
if (goBackCommand) {
items.splice(0, 0, goBackCommand);

+ 4
- 4
src/quickPicks/fileHistory.ts Datei anzeigen

@ -29,7 +29,7 @@ export class FileHistoryQuickPick {
items.splice(0, 0, new CommandQuickPickItem({
label: `$(sync) Show All Commits`,
description: `\u00a0 \u2014 \u00a0\u00a0 this may take a while`
}, Commands.ShowQuickFileHistory, [Uri.file(uri.fsPath), 0, goBackCommand]));
}, Commands.ShowQuickFileHistory, [Uri.file(uri.fsPath), undefined, 0, goBackCommand]));
if (nextPageCommand) {
index++;
@ -40,14 +40,14 @@ export class FileHistoryQuickPick {
const npc = new CommandQuickPickItem({
label: `$(arrow-right) Show Next Commits`,
description: `\u00a0 \u2014 \u00a0\u00a0 shows ${log.maxCount} newer commits`
}, Commands.ShowQuickFileHistory, [uri, log.maxCount, goBackCommand, undefined, nextPageCommand]);
}, Commands.ShowQuickFileHistory, [uri, undefined, log.maxCount, goBackCommand, undefined, nextPageCommand]);
const last = Iterables.last(log.commits.values());
previousPageCommand = new CommandQuickPickItem({
label: `$(arrow-left) Show Previous Commits`,
description: `\u00a0 \u2014 \u00a0\u00a0 shows ${log.maxCount} older commits`
}, Commands.ShowQuickFileHistory, [new GitUri(uri, last), log.maxCount, goBackCommand, undefined, npc]);
}, Commands.ShowQuickFileHistory, [new GitUri(uri, last), undefined, log.maxCount, goBackCommand, undefined, npc]);
index++;
items.splice(0, 0, previousPageCommand);
@ -66,7 +66,7 @@ export class FileHistoryQuickPick {
new CommandQuickPickItem({
label: `go back \u21A9`,
description: `\u00a0 \u2014 \u00a0\u00a0 to history of \u00a0$(file-text) ${path.basename(uri.fsPath)}`
}, Commands.ShowQuickFileHistory, [uri, log.maxCount, undefined, log])
}, Commands.ShowQuickFileHistory, [uri, undefined, log.maxCount, undefined, log])
]));
}

Laden…
Abbrechen
Speichern