浏览代码

Closes #232 - adds Apply Changes to commit file quick pick

main
Eric Amodio 7 年前
父节点
当前提交
5d3e72bfca
共有 1 个文件被更改,包括 26 次插入3 次删除
  1. +26
    -3
      src/quickPicks/commitFileDetails.ts

+ 26
- 3
src/quickPicks/commitFileDetails.ts 查看文件

@ -1,7 +1,7 @@
'use strict';
import { Iterables, Strings } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, openEditor, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './common';
import { GlyphChars } from '../constants';
import { GitLog, GitLogCommit, GitService, GitUri, RemoteResource } from '../gitService';
@ -9,6 +9,25 @@ import { Keyboard, KeyCommand, KeyNoopCommand } from '../keyboard';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as path from 'path';
export class ApplyCommitFileChangesCommandQuickPickItem extends CommandQuickPickItem {
constructor(
private readonly commit: GitLogCommit,
private readonly git: GitService,
item?: QuickPickItem
) {
super(item || {
label: `$(git-pull-request) Apply Changes`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(file-text) ${path.basename(commit.fileName)} in ${GlyphChars.Space}$(git-commit) ${commit.shortSha}`
}, undefined, undefined);
}
async execute(): Promise<{} | undefined> {
const uri = this.commit.toGitUri();
await this.git.checkoutFile(uri);
return openEditor(uri, { preserveFocus: true, preview: false });
}
}
export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
constructor(
@ -66,6 +85,10 @@ export class CommitFileDetailsQuickPick {
await commit.resolvePreviousFileSha(git);
if (stash) {
items.push(new ApplyCommitFileChangesCommandQuickPickItem(commit, git));
}
if (commit.previousFileShortSha) {
items.push(new CommandQuickPickItem({
label: `$(git-compare) Open Changes`,
@ -118,6 +141,8 @@ export class CommitFileDetailsQuickPick {
}
if (!stash) {
items.push(new ApplyCommitFileChangesCommandQuickPickItem(commit, git));
items.push(new CommandQuickPickItem({
label: `$(clippy) Copy Commit ID to Clipboard`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.shortSha}`
@ -139,9 +164,7 @@ export class CommitFileDetailsQuickPick {
sha: commit.sha
} as CopyMessageToClipboardCommandArgs
]));
}
if (!stash) {
items.push(new CommandQuickPickItem({
label: `$(git-commit) Show Commit Details`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha}`

正在加载...
取消
保存