Browse Source

Adds renamed file info into quick pick description

main
Eric Amodio 7 years ago
parent
commit
9071b55026
5 changed files with 31 additions and 17 deletions
  1. +8
    -2
      src/git/models/logCommit.ts
  2. +3
    -3
      src/git/parsers/logParser.ts
  3. +1
    -1
      src/quickPicks/commitDetails.ts
  4. +14
    -10
      src/quickPicks/gitQuickPicks.ts
  5. +5
    -1
      src/quickPicks/repoStatus.ts

+ 8
- 2
src/git/models/logCommit.ts View File

@ -6,10 +6,16 @@ import * as path from 'path';
export type GitLogType = 'file' | 'repo';
export interface IGitLogFileStatusEntry {
status: GitStatusFileStatus;
fileName: string;
originalFileName?: string;
}
export class GitLogCommit extends GitCommit {
fileNames: string;
fileStatuses: { status: GitStatusFileStatus, fileName: string, originalFileName?: string }[];
fileStatuses: IGitLogFileStatusEntry[];
nextSha?: string;
nextFileName?: string;
parentShas: string[];
@ -24,7 +30,7 @@ export class GitLogCommit extends GitCommit {
date: Date,
message: string,
status?: GitStatusFileStatus,
fileStatuses?: { status: GitStatusFileStatus, fileName: string, originalFileName?: string }[],
fileStatuses?: IGitLogFileStatusEntry[],
lines?: IGitCommitLine[],
originalFileName?: string,
previousSha?: string,

+ 3
- 3
src/git/parsers/logParser.ts View File

@ -1,6 +1,6 @@
'use strict';
import { Range } from 'vscode';
import { Git, GitStatusFileStatus, GitLogCommit, GitLogType, IGitAuthor, IGitLog } from './../git';
import { Git, GitStatusFileStatus, GitLogCommit, GitLogType, IGitAuthor, IGitLog, IGitLogFileStatusEntry } from './../git';
// import { Logger } from '../../logger';
import * as moment from 'moment';
import * as path from 'path';
@ -18,7 +18,7 @@ interface ILogEntry {
fileName?: string;
originalFileName?: string;
fileStatuses?: { status: GitStatusFileStatus, fileName: string, originalFileName: string }[];
fileStatuses?: IGitLogFileStatusEntry[];
status?: GitStatusFileStatus;
@ -134,7 +134,7 @@ export class GitLogParser {
status: line[0] as GitStatusFileStatus,
fileName: line.substring(1),
originalFileName: undefined as string
};
} as IGitLogFileStatusEntry;
this._parseFileName(status);
entry.fileStatuses.push(status);

+ 1
- 1
src/quickPicks/commitDetails.ts View File

@ -36,7 +36,7 @@ export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCom
export class CommitDetailsQuickPick {
static async show(git: GitService, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, repoLog?: IGitLog): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs.fileName, fs.status));
const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs));
let index = 0;

+ 14
- 10
src/quickPicks/gitQuickPicks.ts View File

@ -1,6 +1,6 @@
'use strict';
import { QuickPickItem, Uri } from 'vscode';
import { getGitStatusIcon, Git, GitCommit, GitStatusFileStatus, GitService, GitUri } from '../gitService';
import { getGitStatusIcon, Git, GitCommit, GitStatusFileStatus, GitService, GitUri, IGitLogFileStatusEntry } from '../gitService';
import { OpenFileCommandQuickPickItem } from './quickPicks';
import * as moment from 'moment';
import * as path from 'path';
@ -26,23 +26,27 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
shortSha: string;
status: GitStatusFileStatus;
constructor(commit: GitCommit, fileName: string, status: GitStatusFileStatus) {
const icon = getGitStatusIcon(status);
constructor(commit: GitCommit, status: IGitLogFileStatusEntry) {
const icon = getGitStatusIcon(status.status);
let directory = Git.normalizePath(path.dirname(fileName));
let directory = Git.normalizePath(path.dirname(status.fileName));
if (!directory || directory === '.') {
directory = undefined;
}
super(GitService.toGitContentUri(commit.sha, fileName, commit.repoPath, commit.originalFileName), {
label: `\u00a0\u00a0\u00a0\u00a0${icon}\u00a0\u00a0 ${path.basename(fileName)}`,
description: directory
let description = (status.status === 'R' && status.originalFileName)
? `${directory || ''} \u00a0\u2190\u00a0 ${status.originalFileName}`
: directory;
super(GitService.toGitContentUri(commit.sha, status.fileName, commit.repoPath, commit.originalFileName), {
label: `\u00a0\u00a0\u00a0\u00a0${icon}\u00a0\u00a0 ${path.basename(status.fileName)}`,
description: description
});
this.fileName = fileName;
this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, fileName)));
this.fileName = status.fileName;
this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, status.fileName)));
this.sha = commit.sha;
this.shortSha = commit.shortSha;
this.status = status;
this.status = status.status;
}
}

+ 5
- 1
src/quickPicks/repoStatus.ts View File

@ -17,9 +17,13 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
directory = undefined;
}
let description = (status.status === 'R' && status.originalFileName)
? `${directory || ''} \u00a0\u2190\u00a0 ${status.originalFileName}`
: directory;
super(uri, item || {
label: `${status.staged ? '$(check)' : '\u00a0\u00a0\u00a0'}\u00a0\u00a0${icon}\u00a0\u00a0\u00a0${path.basename(status.fileName)}`,
description: directory
description: description
});
}
}

Loading…
Cancel
Save