mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-10 10:12:40 -05:00
Adds copy sha to clipboard to commit quickpick
Adds show changed files to commit quickpick Changes ordering of commit quickpick list
This commit is contained in:
@@ -27,7 +27,7 @@ export class CommitQuickPickItem implements QuickPickItem {
|
|||||||
|
|
||||||
constructor(public commit: GitCommit, descriptionSuffix: string = '') {
|
constructor(public commit: GitCommit, descriptionSuffix: string = '') {
|
||||||
this.label = `${commit.author}, ${moment(commit.date).fromNow()}`;
|
this.label = `${commit.author}, ${moment(commit.date).fromNow()}`;
|
||||||
this.description = `$(git-commit) ${commit.sha}${descriptionSuffix}`;
|
this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}${descriptionSuffix}`;
|
||||||
this.detail = commit.message;
|
this.detail = commit.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,38 +5,52 @@ import { Commands } from '../constants';
|
|||||||
import { GitCommit, GitUri, IGitLog } from '../gitProvider';
|
import { GitCommit, GitUri, IGitLog } from '../gitProvider';
|
||||||
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems';
|
import { CommandQuickPickItem, CommitQuickPickItem, FileQuickPickItem } from './quickPickItems';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
export class CommitQuickPick {
|
export class CommitQuickPick {
|
||||||
|
|
||||||
static async show(commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
|
static async show(commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
|
||||||
const items: CommandQuickPickItem[] = [
|
const items: CommandQuickPickItem[] = [];
|
||||||
new CommandQuickPickItem({
|
|
||||||
label: `$(diff) Compare with Working Tree`,
|
|
||||||
description: `$(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingFileName || commit.fileName}`
|
|
||||||
}, Commands.DiffWithWorking, [uri, commit])
|
|
||||||
];
|
|
||||||
|
|
||||||
if (commit.previousSha) {
|
if (commit.previousSha) {
|
||||||
items.push(new CommandQuickPickItem({
|
items.push(new CommandQuickPickItem({
|
||||||
label: `$(diff) Compare with Previous Commit`,
|
label: `$(git-compare) Compare with Previous Commit`,
|
||||||
description: `$(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`
|
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`
|
||||||
}, Commands.DiffWithPrevious, [commit.uri, commit]));
|
}, Commands.DiffWithPrevious, [commit.uri, commit]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.showFileHistory) {
|
items.push(new CommandQuickPickItem({
|
||||||
items.push(new CommandQuickPickItem({
|
label: `$(git-compare) Compare with Working Tree`,
|
||||||
label: `$(versions) Show Previous Commit History`,
|
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingFileName || commit.fileName}`
|
||||||
description: `\u2022 ${commit.fileName}`,
|
}, Commands.DiffWithWorking, [uri, commit]));
|
||||||
detail: `Shows the previous commit history starting at $(git-commit) ${commit.sha}`
|
|
||||||
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, undefined, currentCommand]));
|
|
||||||
|
|
||||||
|
items.push(new CommandQuickPickItem({
|
||||||
|
label: `$(clippy) Copy Commit Sha to Clipboard`,
|
||||||
|
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}`
|
||||||
|
}, Commands.CopyShaToClipboard, [uri, commit.sha]));
|
||||||
|
|
||||||
|
items.push(new CommandQuickPickItem({
|
||||||
|
label: `$(diff) Show Changed Files`,
|
||||||
|
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}`,
|
||||||
|
detail: `Shows all the changed files in commit $(git-commit) ${commit.sha}`
|
||||||
|
}, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), commit.sha, undefined, currentCommand]));
|
||||||
|
|
||||||
|
if (options.showFileHistory) {
|
||||||
|
const fileName = path.basename(commit.fileName);
|
||||||
|
fileName;
|
||||||
if (workingFileName) {
|
if (workingFileName) {
|
||||||
items.push(new CommandQuickPickItem({
|
items.push(new CommandQuickPickItem({
|
||||||
label: `$(versions) Show Commit History`,
|
label: `$(versions) Show Commit History`,
|
||||||
description: `\u2022 ${commit.fileName}`,
|
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.fileName}`,
|
||||||
detail: `Shows the commit history starting at the most recent commit`
|
detail: `Shows the commit history of the file, starting at the most recent commit`
|
||||||
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, undefined, currentCommand]));
|
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, undefined, currentCommand]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
items.push(new CommandQuickPickItem({
|
||||||
|
label: `$(versions) Show Previous Commit History`,
|
||||||
|
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.fileName}`,
|
||||||
|
detail: `Shows the previous commit history of the file, starting at $(git-commit) ${commit.sha}`
|
||||||
|
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, undefined, currentCommand]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goBackCommand) {
|
if (goBackCommand) {
|
||||||
@@ -78,7 +92,7 @@ export class FileCommitsQuickPick {
|
|||||||
if (maxCount !== 0 && items.length >= defaultMaxCount) {
|
if (maxCount !== 0 && items.length >= defaultMaxCount) {
|
||||||
items.splice(0, 0, new CommandQuickPickItem({
|
items.splice(0, 0, new CommandQuickPickItem({
|
||||||
label: `$(sync) Show All Commits`,
|
label: `$(sync) Show All Commits`,
|
||||||
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
|
description: `\u00a0 \u2014 \u00a0\u00a0 Currently only showing the first ${defaultMaxCount} commits`,
|
||||||
detail: `This may take a while`
|
detail: `This may take a while`
|
||||||
}, Commands.ShowQuickFileHistory, [uri, 0, undefined, goBackCommand]));
|
}, Commands.ShowQuickFileHistory, [uri, 0, undefined, goBackCommand]));
|
||||||
}
|
}
|
||||||
@@ -115,7 +129,7 @@ export class RepoCommitsQuickPick {
|
|||||||
if (maxCount !== 0 && items.length >= defaultMaxCount) {
|
if (maxCount !== 0 && items.length >= defaultMaxCount) {
|
||||||
items.splice(0, 0, new CommandQuickPickItem({
|
items.splice(0, 0, new CommandQuickPickItem({
|
||||||
label: `$(sync) Show All Commits`,
|
label: `$(sync) Show All Commits`,
|
||||||
description: `\u2014 Currently only showing the first ${defaultMaxCount} commits`,
|
description: `\u00a0 \u2014 \u00a0\u00a0 Currently only showing the first ${defaultMaxCount} commits`,
|
||||||
detail: `This may take a while`
|
detail: `This may take a while`
|
||||||
}, Commands.ShowQuickRepoHistory, [uri, 0, undefined, goBackCommand]));
|
}, Commands.ShowQuickRepoHistory, [uri, 0, undefined, goBackCommand]));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user