From e0bf4eb8205908ae20a3fecb23c731cb9daac420 Mon Sep 17 00:00:00 2001 From: Till Date: Tue, 21 Nov 2017 11:40:59 +0100 Subject: [PATCH] Reuse last commit message for amend fixes #35182 --- extensions/git/src/commands.ts | 11 ++++++++++- extensions/git/src/repository.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index dc1774aea46..57a1701510e 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -979,6 +979,7 @@ export class CommandCenter { } return await window.showInputBox({ + value: opts && opts.defaultMsg, placeHolder: localize('commit message', "Commit message"), prompt: localize('provide commit message', "Please provide a commit message"), ignoreFocusOut: true @@ -1022,7 +1023,15 @@ export class CommandCenter { @command('git.commitStagedAmend', { repository: true }) async commitStagedAmend(repository: Repository): Promise { - await this.commitWithAnyInput(repository, { all: false, amend: true }); + let msg; + if (repository.HEAD) { + if (repository.HEAD.commit) { + let id = repository.HEAD.commit; + let commit = await repository.getCommit(id); + msg = commit.message; + } + } + await this.commitWithAnyInput(repository, { all: false, amend: true, defaultMsg: msg }); } @command('git.commitAll', { repository: true }) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 826b27bff8a..93e8386e440 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -374,6 +374,7 @@ export interface CommitOptions { amend?: boolean; signoff?: boolean; signCommit?: boolean; + defaultMsg?: string; } export interface GitResourceGroup extends SourceControlResourceGroup { -- GitLab