From a5be6f05332d7a39012bbe37a2991898fe9060c1 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 10 Apr 2017 12:50:23 -0400 Subject: [PATCH] Closes #63 - Switch commit message and author in commit pick list --- src/git/models/logCommit.ts | 7 +++++++ src/quickPicks/commitDetails.ts | 6 +----- src/quickPicks/common.ts | 12 ++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/git/models/logCommit.ts b/src/git/models/logCommit.ts index b79d1bb..11995d8 100644 --- a/src/git/models/logCommit.ts +++ b/src/git/models/logCommit.ts @@ -51,4 +51,11 @@ export class GitLogCommit extends GitCommit { get nextUri(): Uri { return this.nextFileName ? Uri.file(path.resolve(this.repoPath, this.nextFileName)) : this.uri; } + + getDiffStatus(): string { + const added = this.fileStatuses.filter(_ => _.status === 'A' || _.status === '?').length; + const deleted = this.fileStatuses.filter(_ => _.status === 'D').length; + const changed = this.fileStatuses.filter(_ => _.status !== 'A' && _.status !== '?' && _.status !== 'D').length; + return `+${added} ~${changed} -${deleted}`; + } } \ No newline at end of file diff --git a/src/quickPicks/commitDetails.ts b/src/quickPicks/commitDetails.ts index 3cb2be0..b93d6d6 100644 --- a/src/quickPicks/commitDetails.ts +++ b/src/quickPicks/commitDetails.ts @@ -117,13 +117,9 @@ export class CommitDetailsQuickPick { description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha} \u00a0 $(git-compare) \u00a0 $(file-directory) Working Tree` }, Commands.DiffDirectory, [uri, commit.sha])); - const added = commit.fileStatuses.filter(_ => _.status === 'A' || _.status === '?').length; - const deleted = commit.fileStatuses.filter(_ => _.status === 'D').length; - const changed = commit.fileStatuses.filter(_ => _.status !== 'A' && _.status !== '?' && _.status !== 'D').length; - items.splice(index++, 0, new CommandQuickPickItem({ label: `Changed Files`, - description: `+${added} ~${changed} -${deleted}` + description: commit.getDiffStatus() }, Commands.ShowQuickCommitDetails, [uri, commit.sha, commit, goBackCommand, repoLog])); items.push(new OpenCommitFilesCommandQuickPickItem(commit)); diff --git a/src/quickPicks/common.ts b/src/quickPicks/common.ts index 1d97b1c..2e6d982 100644 --- a/src/quickPicks/common.ts +++ b/src/quickPicks/common.ts @@ -118,14 +118,14 @@ export class CommitQuickPickItem implements QuickPickItem { constructor(public commit: GitCommit) { if (commit instanceof GitStashCommit) { - this.label = `${commit.stashName}, ${moment(commit.date).fromNow()}`; - this.description = `\u00a0\u00a0\u2014\u00a0\u00a0 ${commit.fileNames}`; //\u00a0\u00a0 $(git-commit) ${commit.shortSha} + this.label = `${commit.stashName}\u00a0\u2022\u00a0${commit.message}`; + this.description = null; + this.detail = `\u00a0 ${moment(commit.date).fromNow()}\u00a0\u00a0\u2022\u00a0 ${commit.getDiffStatus()}`; } else { - this.label = `${commit.author}, ${moment(commit.date).fromNow()}`; - const suffix = commit.type === 'branch' ? ` \u2014 ${(commit as GitLogCommit).fileNames}` : ''; - this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}${suffix}`; + this.label = commit.message; + this.description = `\u00a0$(git-commit)\u00a0 ${commit.shortSha}`; + this.detail = `\u00a0 ${commit.author}, ${moment(commit.date).fromNow()}${(commit.type === 'branch') ? `\u00a0\u00a0\u2022\u00a0 ${(commit as GitLogCommit).getDiffStatus()}` : ''}`; } - this.detail = commit.message; } } \ No newline at end of file