mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Git: Add cherryPick command
This commit is contained in:
@@ -2027,6 +2027,21 @@ export class CommandCenter {
|
||||
await this._push(repository, { pushType: PushType.PushFollowTags, forcePush: true });
|
||||
}
|
||||
|
||||
@command('git.cherryPick', { repository: true })
|
||||
async cherryPick(repository: Repository): Promise<void> {
|
||||
const inputCommitHash = await window.showInputBox({
|
||||
placeHolder: localize('commit hash', "Commit Hash"),
|
||||
prompt: localize('provide commit hash', "Please provide the commit hash"),
|
||||
ignoreFocusOut: true
|
||||
});
|
||||
|
||||
if (!inputCommitHash) {
|
||||
return;
|
||||
}
|
||||
|
||||
await repository.cherryPick(inputCommitHash);
|
||||
}
|
||||
|
||||
@command('git.pushTo', { repository: true })
|
||||
async pushTo(repository: Repository): Promise<void> {
|
||||
await this._push(repository, { pushType: PushType.PushTo });
|
||||
|
||||
@@ -1635,6 +1635,11 @@ export class Repository {
|
||||
}
|
||||
}
|
||||
|
||||
async cherryPick(commitHash: string): Promise<void> {
|
||||
const args = ['cherry-pick', commitHash];
|
||||
await this.run(args);
|
||||
}
|
||||
|
||||
async blame(path: string): Promise<string> {
|
||||
try {
|
||||
const args = ['blame', sanitizePath(path)];
|
||||
|
||||
@@ -294,6 +294,7 @@ export const enum Operation {
|
||||
Fetch = 'Fetch',
|
||||
Pull = 'Pull',
|
||||
Push = 'Push',
|
||||
CherryPick = 'CherryPick',
|
||||
Sync = 'Sync',
|
||||
Show = 'Show',
|
||||
Stage = 'Stage',
|
||||
@@ -1195,6 +1196,10 @@ export class Repository implements Disposable {
|
||||
await this.run(Operation.Push, () => this._push(remote, undefined, false, true, forcePushMode));
|
||||
}
|
||||
|
||||
async cherryPick(commitHash: string): Promise<void> {
|
||||
await this.run(Operation.CherryPick, () => this.repository.cherryPick(commitHash));
|
||||
}
|
||||
|
||||
async blame(path: string): Promise<string> {
|
||||
return await this.run(Operation.Blame, () => this.repository.blame(path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user