mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Git - Add merge abort command (#159753)
* Add merge abort command * Pull request feedback
This commit is contained in:
parent
c6fd3c9c17
commit
1e99736c27
|
@ -369,6 +369,11 @@
|
|||
"title": "%command.merge%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.mergeAbort",
|
||||
"title": "%command.mergeAbort%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.rebase",
|
||||
"title": "%command.rebase%",
|
||||
|
@ -898,6 +903,10 @@
|
|||
"command": "git.merge",
|
||||
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
|
||||
},
|
||||
{
|
||||
"command": "git.mergeAbort",
|
||||
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && gitMergeInProgress"
|
||||
},
|
||||
{
|
||||
"command": "git.rebase",
|
||||
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
"command.renameBranch": "Rename Branch...",
|
||||
"command.cherryPick": "Cherry Pick...",
|
||||
"command.merge": "Merge Branch...",
|
||||
"command.mergeAbort": "Abort Merge",
|
||||
"command.rebase": "Rebase Branch...",
|
||||
"command.createTag": "Create Tag",
|
||||
"command.deleteTag": "Delete Tag",
|
||||
|
|
|
@ -205,7 +205,7 @@ export class ActionButtonCommand {
|
|||
this.state = {
|
||||
...this.state,
|
||||
HEAD: this.repository.HEAD,
|
||||
isMergeInProgress: this.repository.mergeGroup.resourceStates.length !== 0,
|
||||
isMergeInProgress: this.repository.mergeInProgress,
|
||||
isRebaseInProgress: !!this.repository.rebaseCommit,
|
||||
repositoryHasChangesToCommit: this.repositoryHasChangesToCommit()
|
||||
};
|
||||
|
|
|
@ -2202,6 +2202,11 @@ export class CommandCenter {
|
|||
await choice.run(repository);
|
||||
}
|
||||
|
||||
@command('git.mergeAbort', { repository: true })
|
||||
async abortMerge(repository: Repository): Promise<void> {
|
||||
await repository.mergeAbort();
|
||||
}
|
||||
|
||||
@command('git.rebase', { repository: true })
|
||||
async rebase(repository: Repository): Promise<void> {
|
||||
const config = workspace.getConfiguration('git');
|
||||
|
|
|
@ -1570,6 +1570,10 @@ export class Repository {
|
|||
}
|
||||
}
|
||||
|
||||
async mergeAbort(): Promise<void> {
|
||||
await this.exec(['merge', '--abort']);
|
||||
}
|
||||
|
||||
async tag(name: string, message?: string): Promise<void> {
|
||||
let args = ['tag'];
|
||||
|
||||
|
|
|
@ -336,6 +336,7 @@ export const enum Operation {
|
|||
RenameBranch = 'RenameBranch',
|
||||
DeleteRef = 'DeleteRef',
|
||||
Merge = 'Merge',
|
||||
MergeAbort = 'MergeAbort',
|
||||
Rebase = 'Rebase',
|
||||
Ignore = 'Ignore',
|
||||
Tag = 'Tag',
|
||||
|
@ -840,6 +841,17 @@ export class Repository implements Disposable {
|
|||
return this._rebaseCommit;
|
||||
}
|
||||
|
||||
private _mergeInProgress: boolean = false;
|
||||
|
||||
set mergeInProgress(value: boolean) {
|
||||
this._mergeInProgress = value;
|
||||
commands.executeCommand('setContext', 'gitMergeInProgress', value);
|
||||
}
|
||||
|
||||
get mergeInProgress() {
|
||||
return this._mergeInProgress;
|
||||
}
|
||||
|
||||
private _operations = new OperationsImpl();
|
||||
get operations(): Operations { return this._operations; }
|
||||
|
||||
|
@ -1365,6 +1377,10 @@ export class Repository implements Disposable {
|
|||
await this.run(Operation.Merge, () => this.repository.merge(ref));
|
||||
}
|
||||
|
||||
async mergeAbort(): Promise<void> {
|
||||
await this.run(Operation.MergeAbort, async () => await this.repository.mergeAbort());
|
||||
}
|
||||
|
||||
async rebase(branch: string): Promise<void> {
|
||||
await this.run(Operation.Rebase, () => this.repository.rebase(branch));
|
||||
}
|
||||
|
@ -1990,13 +2006,14 @@ export class Repository implements Disposable {
|
|||
if (sort !== 'alphabetically' && sort !== 'committerdate') {
|
||||
sort = 'alphabetically';
|
||||
}
|
||||
const [refs, remotes, submodules, rebaseCommit] = await Promise.all([this.repository.getRefs({ sort }), this.repository.getRemotes(), this.repository.getSubmodules(), this.getRebaseCommit()]);
|
||||
const [refs, remotes, submodules, rebaseCommit, mergeInProgress] = await Promise.all([this.repository.getRefs({ sort }), this.repository.getRemotes(), this.repository.getSubmodules(), this.getRebaseCommit(), this.isMergeInProgress()]);
|
||||
|
||||
this._HEAD = HEAD;
|
||||
this._refs = refs!;
|
||||
this._remotes = remotes!;
|
||||
this._submodules = submodules!;
|
||||
this.rebaseCommit = rebaseCommit;
|
||||
this.mergeInProgress = mergeInProgress;
|
||||
|
||||
const index: Resource[] = [];
|
||||
const workingTree: Resource[] = [];
|
||||
|
@ -2110,6 +2127,11 @@ export class Repository implements Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
private isMergeInProgress(): Promise<boolean> {
|
||||
const mergeHeadPath = path.join(this.repository.root, '.git', 'MERGE_HEAD');
|
||||
return new Promise<boolean>(resolve => fs.exists(mergeHeadPath, resolve));
|
||||
}
|
||||
|
||||
private async maybeAutoStash<T>(runOperation: () => Promise<T>): Promise<T> {
|
||||
const config = workspace.getConfiguration('git', Uri.file(this.root));
|
||||
const shouldAutoStash = config.get<boolean>('autoStash')
|
||||
|
|
Loading…
Reference in a new issue