Skip to content

Commit

Permalink
commit action in command palette
Browse files Browse the repository at this point in the history
fixes #4471
  • Loading branch information
joaomoreno committed Apr 5, 2016
1 parent 4333abe commit c01d286
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {IFileService} from 'vs/platform/files/common/files';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import wbar = require('vs/workbench/common/actionRegistry');
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { OpenChangeAction, OpenFileAction, SyncAction, PullAction, PushAction, PublishAction, StartGitBranchAction, StartGitCheckoutAction } from './gitActions';
import { OpenChangeAction, OpenFileAction, SyncAction, PullAction, PushAction, PublishAction, StartGitBranchAction, StartGitCheckoutAction, InputCommitAction } from './gitActions';
import paths = require('vs/base/common/paths');
import URI from 'vs/base/common/uri';

Expand Down Expand Up @@ -478,3 +478,4 @@ workbenchActionRegistry.registerWorkbenchAction(new SyncActionDescriptor(SyncAct
workbenchActionRegistry.registerWorkbenchAction(new SyncActionDescriptor(PublishAction, PublishAction.ID, PublishAction.LABEL), category);
workbenchActionRegistry.registerWorkbenchAction(new SyncActionDescriptor(StartGitBranchAction, StartGitBranchAction.ID, StartGitBranchAction.LABEL), category);
workbenchActionRegistry.registerWorkbenchAction(new SyncActionDescriptor(StartGitCheckoutAction, StartGitCheckoutAction.ID, StartGitCheckoutAction.LABEL), category);
workbenchActionRegistry.registerWorkbenchAction(new SyncActionDescriptor(InputCommitAction, InputCommitAction.ID, InputCommitAction.LABEL), category);
40 changes: 40 additions & 0 deletions src/vs/workbench/parts/git/browser/gitActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,46 @@ export class CommitAction extends BaseCommitAction {

}

export class InputCommitAction extends GitAction {

static ID = 'workbench.action.git.input-commit';
static LABEL = nls.localize('commit', "Commit");

constructor(
id = InputCommitAction.ID,
label = InputCommitAction.LABEL,
@IGitService gitService: IGitService,
@IQuickOpenService private quickOpenService: IQuickOpenService
) {
super(id, label, '', gitService);
}

protected isEnabled():boolean {
if (!this.gitService) {
return false;
}

if (!this.gitService.isIdle()) {
return false;
}

const status = this.gitService.getModel().getStatus();

return status.getIndexStatus().all().length > 0 || status.getWorkingTreeStatus().all().length > 0;
}

run(): TPromise<any> {
if (!this.enabled) {
return TPromise.as(null);
}

const status = this.gitService.getModel().getStatus();

return this.quickOpenService.input({ prompt: 'Commit Message' })
.then(message => message && this.gitService.commit(message, false, status.getIndexStatus().all().length === 0));
}
}

export class StageAndCommitAction extends BaseCommitAction {

static ID = 'workbench.action.git.stageAndCommit';
Expand Down

0 comments on commit c01d286

Please sign in to comment.