提交 4753a000 编写于 作者: W William Raiford

Restore prev commit msg using `IStorageService`

* Added line in `UndoLastCommitAction` to get the previous commit msg and store in `IStorageService`.
* Added `UpdateCommitInputPrevCommitMsg` that checks for that key in storage, and use it then remove it if it exists.
  * This does not suffer from the previous bug that blanked out the commit msg if you unstage a file.
  * Added a clause if the undo last commit fails to remove the key from storage. This way, it doesn't stay in there and get used later (I was scratching my head when it showed up later).
上级 8a92ee5a
......@@ -29,6 +29,7 @@ import { IGitService, IFileStatus, Status, StatusType, ServiceState, IModel, IBr
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
import paths = require('vs/base/common/paths');
import URI from 'vs/base/common/uri';
import { IStorageService } from 'vs/platform/storage/common/storage';
function flatten(context?: any, preferFocus = false): IFileStatus[] {
if (!context) {
......@@ -1117,13 +1118,14 @@ export class UndoLastCommitAction extends GitAction {
constructor(
id = UndoLastCommitAction.ID,
label = UndoLastCommitAction.LABEL,
@IGitService gitService: IGitService
@IGitService gitService: IGitService,
@IStorageService private storageService: IStorageService
) {
super(UndoLastCommitAction.ID, UndoLastCommitAction.LABEL, 'git-action undo-last-commit', gitService);
}
public run():Promise {
return this.gitService.reset('HEAD~');
return this.gitService.getLog({ prevCount: 1, format: '%B' }).then(prevCommitMsg => this.storageService.store('prevCommitMsg', prevCommitMsg)).then(_ => this.gitService.reset('HEAD~'));
}
}
......
......@@ -41,6 +41,7 @@ import {IEventService} from 'vs/platform/event/common/event';
import {CommonKeybindings} from 'vs/base/common/keyCodes';
import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IStorageService} from 'vs/platform/storage/common/storage';
import IGitService = git.IGitService;
......@@ -89,7 +90,8 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
@IGitService gitService: IGitService,
@IOutputService outputService: IOutputService,
@IEventService eventService: IEventService,
@IConfigurationService private configurationService: IConfigurationService
@IConfigurationService private configurationService: IConfigurationService,
@IStorageService private storageService: IStorageService
) {
super();
......@@ -244,6 +246,14 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
}
}
private updateCommitInputPrevCommitMsg(): void {
let prevCommitMsg = this.storageService.get('prevCommitMsg');
if (prevCommitMsg) {
this.commitInputBox.value = prevCommitMsg;
this.storageService.remove('prevCommitMsg');
}
}
private updateCommitInputTemplate(): void {
if (this.commitInputBox.value) {
return;
......@@ -414,6 +424,12 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
this.updateCommitInputTemplate();
}
}
} else if (e.operation.id === git.ServiceOperations.RESET) {
if (!e.error) {
this.updateCommitInputPrevCommitMsg();
} else {
this.storageService.remove('prevCommitMsg');
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册