clean up git actions
This commit is contained in:
parent
bece7e9c01
commit
a417227e34
|
@ -723,8 +723,10 @@ export abstract class BaseCommitAction extends GitAction {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
return this.gitService.commit(this.commitState.getCommitMessage());
|
||||
return this.commit();
|
||||
}
|
||||
|
||||
protected abstract commit(): Promise;
|
||||
}
|
||||
|
||||
export class CommitAction extends BaseCommitAction {
|
||||
|
@ -735,6 +737,9 @@ export class CommitAction extends BaseCommitAction {
|
|||
super(commitState, CommitAction.ID, nls.localize('commitStaged', "Commit Staged"), 'git-action commit', gitService);
|
||||
}
|
||||
|
||||
protected commit(): Promise {
|
||||
return this.gitService.commit(this.commitState.getCommitMessage());
|
||||
}
|
||||
}
|
||||
|
||||
export class CommitSignedOffAction extends BaseCommitAction {
|
||||
|
@ -745,12 +750,7 @@ export class CommitSignedOffAction extends BaseCommitAction {
|
|||
super(commitState, CommitAction.ID, nls.localize('commitStagedSignedOff', "Commit Staged (Signed Off)"), 'git-action commit-signed-off', gitService);
|
||||
}
|
||||
|
||||
public run(context?: any):Promise {
|
||||
if (!this.commitState.getCommitMessage()) {
|
||||
this.commitState.onEmptyCommitMessage();
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
protected commit(): Promise {
|
||||
return this.gitService.commit(this.commitState.getCommitMessage(), undefined, undefined, true);
|
||||
}
|
||||
}
|
||||
|
@ -798,9 +798,17 @@ export class InputCommitAction extends GitAction {
|
|||
export class StageAndCommitAction extends BaseCommitAction {
|
||||
|
||||
static ID = 'workbench.action.git.stageAndCommit';
|
||||
static LABEL = nls.localize('commitAll', "Commit All");
|
||||
static CSSCLASS = 'git-action stage-and-commit';
|
||||
|
||||
constructor(commitState: ICommitState, @IGitService gitService: IGitService) {
|
||||
super(commitState, StageAndCommitAction.ID, nls.localize('commitAll', "Commit All"), 'git-action stage-and-commit', gitService);
|
||||
constructor(
|
||||
commitState: ICommitState,
|
||||
id: string = StageAndCommitAction.ID,
|
||||
label: string = StageAndCommitAction.LABEL,
|
||||
cssClass: string = StageAndCommitAction.CSSCLASS,
|
||||
@IGitService gitService: IGitService
|
||||
) {
|
||||
super(commitState, id, label, cssClass, gitService);
|
||||
}
|
||||
|
||||
protected isEnabled():boolean {
|
||||
|
@ -818,17 +826,12 @@ export class StageAndCommitAction extends BaseCommitAction {
|
|||
|| status.getWorkingTreeStatus().all().length > 0;
|
||||
}
|
||||
|
||||
public run(context?: any):Promise {
|
||||
if (!this.commitState.getCommitMessage()) {
|
||||
this.commitState.onEmptyCommitMessage();
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
protected commit(): Promise {
|
||||
return this.gitService.commit(this.commitState.getCommitMessage(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
export class StageAndCommitSignedOffAction extends BaseCommitAction {
|
||||
export class StageAndCommitSignedOffAction extends StageAndCommitAction {
|
||||
|
||||
static ID = 'workbench.action.git.stageAndCommitSignedOff';
|
||||
|
||||
|
@ -836,27 +839,7 @@ export class StageAndCommitSignedOffAction extends BaseCommitAction {
|
|||
super(commitState, StageAndCommitAction.ID, nls.localize('commitAllSignedOff', "Commit All (Signed Off)"), 'git-action stage-and-commit-signed-off', gitService);
|
||||
}
|
||||
|
||||
protected isEnabled():boolean {
|
||||
if (!this.gitService) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.gitService.isIdle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var status = this.gitService.getModel().getStatus();
|
||||
|
||||
return status.getIndexStatus().all().length > 0
|
||||
|| status.getWorkingTreeStatus().all().length > 0;
|
||||
}
|
||||
|
||||
public run(context?: any):Promise {
|
||||
if (!this.commitState.getCommitMessage()) {
|
||||
this.commitState.onEmptyCommitMessage();
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
protected commit(): Promise {
|
||||
return this.gitService.commit(this.commitState.getCommitMessage(), false, true, true);
|
||||
}
|
||||
}
|
||||
|
@ -909,14 +892,8 @@ export class SmartCommitAction extends BaseCommitAction {
|
|||
|| status.getWorkingTreeStatus().all().length > 0;
|
||||
}
|
||||
|
||||
public run(context?: any):Promise {
|
||||
if (!this.commitState.getCommitMessage()) {
|
||||
this.commitState.onEmptyCommitMessage();
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
var status = this.gitService.getModel().getStatus();
|
||||
|
||||
protected commit(): Promise {
|
||||
const status = this.gitService.getModel().getStatus();
|
||||
return this.gitService.commit(this.commitState.getCommitMessage(), false, status.getIndexStatus().all().length === 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
|||
new ActionBar.Separator(),
|
||||
this.instantiationService.createInstance(GitActions.CommitAction, this),
|
||||
this.instantiationService.createInstance(GitActions.CommitSignedOffAction, this),
|
||||
this.instantiationService.createInstance(GitActions.StageAndCommitAction, this),
|
||||
this.instantiationService.createInstance(GitActions.StageAndCommitAction, this, GitActions.StageAndCommitAction.ID, GitActions.StageAndCommitAction.LABEL, GitActions.StageAndCommitAction.CSSCLASS),
|
||||
this.instantiationService.createInstance(GitActions.StageAndCommitSignedOffAction, this),
|
||||
this.instantiationService.createInstance(GitActions.UndoLastCommitAction, GitActions.UndoLastCommitAction.ID, GitActions.UndoLastCommitAction.LABEL),
|
||||
new ActionBar.Separator(),
|
||||
|
|
Loading…
Reference in a new issue