From ba9881227271c20eab6337d669a2d2f41bf11642 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 6 Jul 2018 15:31:43 +0200 Subject: [PATCH] :lipstick: --- extensions/git/src/commands.ts | 5 ++++- extensions/git/src/git.ts | 6 +++--- extensions/git/src/test/git.test.ts | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 3ebf2045b12..b910537bffe 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1172,16 +1172,19 @@ export class CommandCenter { const HEAD = repository.HEAD; if (!HEAD || !HEAD.commit) { + window.showWarningMessage(localize('no more', "Can't undo because HEAD doesn't point to any commit.")); return; } const commit = await repository.getCommit('HEAD'); - if (commit.previousHashes.length > 0) { + + if (commit.parents.length > 0) { await repository.reset('HEAD~'); } else { await repository.deleteRef('HEAD'); await this.unstageAll(repository); } + repository.inputBox.value = commit.message; } diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 14742452f66..b748675b56d 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -501,7 +501,7 @@ export class Git { export interface Commit { hash: string; message: string; - previousHashes: string[]; + parents: string[]; } export class GitStatusParser { @@ -638,8 +638,8 @@ export function parseGitCommit(raw: string): Commit | null { return null; } - const previousHashes = match[2] ? match[2].split(' ') : []; - return { hash: match[1], message: match[3], previousHashes }; + const parents = match[2] ? match[2].split(' ') : []; + return { hash: match[1], message: match[3], parents }; } export interface DiffOptions { diff --git a/extensions/git/src/test/git.test.ts b/extensions/git/src/test/git.test.ts index a1c5e196cfa..781f91b6f00 100644 --- a/extensions/git/src/test/git.test.ts +++ b/extensions/git/src/test/git.test.ts @@ -177,7 +177,7 @@ suite('git', () => { }); suite('parseGitCommit', () => { - test('single previous commit', () => { + test('single parent commit', () => { const GIT_OUTPUT_SINGLE_PARENT = `52c293a05038d865604c2284aa8698bd087915a1 8e5a374372b8393906c7e380dbb09349c5385554 This is a commit message.`; @@ -185,11 +185,11 @@ This is a commit message.`; assert.deepEqual(parseGitCommit(GIT_OUTPUT_SINGLE_PARENT), { hash: '52c293a05038d865604c2284aa8698bd087915a1', message: 'This is a commit message.', - previousHashes: ['8e5a374372b8393906c7e380dbb09349c5385554'] + parents: ['8e5a374372b8393906c7e380dbb09349c5385554'] }); }); - test('multiple previous commits', () => { + test('multiple parent commits', () => { const GIT_OUTPUT_MULTIPLE_PARENTS = `52c293a05038d865604c2284aa8698bd087915a1 8e5a374372b8393906c7e380dbb09349c5385554 df27d8c75b129ab9b178b386077da2822101b217 This is a commit message.`; @@ -197,11 +197,11 @@ This is a commit message.`; assert.deepEqual(parseGitCommit(GIT_OUTPUT_MULTIPLE_PARENTS), { hash: '52c293a05038d865604c2284aa8698bd087915a1', message: 'This is a commit message.', - previousHashes: ['8e5a374372b8393906c7e380dbb09349c5385554', 'df27d8c75b129ab9b178b386077da2822101b217'] + parents: ['8e5a374372b8393906c7e380dbb09349c5385554', 'df27d8c75b129ab9b178b386077da2822101b217'] }); }); - test('no previous commits', async () => { + test('no parent commits', async () => { const GIT_OUTPUT_NO_PARENTS = `52c293a05038d865604c2284aa8698bd087915a1 This is a commit message.`; @@ -209,7 +209,7 @@ This is a commit message.`; assert.deepEqual(parseGitCommit(GIT_OUTPUT_NO_PARENTS), { hash: '52c293a05038d865604c2284aa8698bd087915a1', message: 'This is a commit message.', - previousHashes: [] + parents: [] }); }); }); -- GitLab