From 7c9e9e5722b38c9fd484f79dbdeabbce0ce0c3e0 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Thu, 24 Mar 2022 17:50:43 +0100 Subject: [PATCH 1/2] chore(ci): parse commits correctly --- .../__tests__/create-release-issue.test.ts | 40 ++++++++++++------- scripts/release/create-release-issue.ts | 5 ++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/scripts/release/__tests__/create-release-issue.test.ts b/scripts/release/__tests__/create-release-issue.test.ts index dd9a819541..ba1c9edb25 100644 --- a/scripts/release/__tests__/create-release-issue.test.ts +++ b/scripts/release/__tests__/create-release-issue.test.ts @@ -17,27 +17,37 @@ describe('create release issue', () => { }); it('parses commit', () => { - expect(parseCommit(`abcdefg fix(javascript): fix the thing`)).toEqual({ - hash: 'abcdefg', + expect(parseCommit(`b2501882 fix(javascript): fix the thing`)).toEqual({ + hash: 'b2501882', lang: 'javascript', message: 'fix the thing', - raw: 'abcdefg fix(javascript): fix the thing', + raw: 'b2501882 fix(javascript): fix the thing', type: 'fix', }); }); it('returns error when language scope is missing', () => { - expect(parseCommit(`abcdefg fix: fix the thing`)).toEqual({ + expect(parseCommit(`b2501882 fix: fix the thing`)).toEqual({ error: 'missing-language-scope', }); }); it('returns error when language scope is unknown', () => { - expect(parseCommit(`abcdefg fix(basic): fix the thing`)).toEqual({ + expect(parseCommit(`b2501882 fix(basic): fix the thing`)).toEqual({ error: 'unknown-language-scope', }); }); + it('asdfa', () => { + expect(parseCommit(`5b70cadc feat(java): CTS APIC-253 (#102)`)).toEqual({ + hash: '5b70cadc', + lang: 'java', + message: 'CTS APIC-253 (#102)', + raw: '5b70cadc feat(java): CTS APIC-253 (#102)', + type: 'feat', + }); + }); + it('generates text for version changes', () => { expect( getVersionChangesText({ @@ -125,11 +135,11 @@ describe('create release issue', () => { }, commits: [ { - hash: 'abcdefg', + hash: 'b2501882', type: 'feat', lang: 'javascript', message: 'update the API (BREAKING CHANGE)', - raw: 'abcdefg feat(javascript): update the API (BREAKING CHANGE)', + raw: 'b2501882 feat(javascript): update the API (BREAKING CHANGE)', }, ], }); @@ -152,11 +162,11 @@ describe('create release issue', () => { }, commits: [ { - hash: 'abcdefg', + hash: 'b2501882', type: 'feat', lang: 'php', message: 'update the API', - raw: 'abcdefg feat(php): update the API', + raw: 'b2501882 feat(php): update the API', }, ], }); @@ -179,11 +189,11 @@ describe('create release issue', () => { }, commits: [ { - hash: 'abcdefg', + hash: 'b2501882', type: 'fix', lang: 'java', message: 'fix some bug', - raw: 'abcdefg fix(java): fix some bug', + raw: 'b2501882 fix(java): fix some bug', }, ], }); @@ -206,11 +216,11 @@ describe('create release issue', () => { }, commits: [ { - hash: 'abcdefg', + hash: 'b2501882', type: 'fix', lang: 'java', message: 'fix some bug', - raw: 'abcdefg fix(java): fix some bug', + raw: 'b2501882 fix(java): fix some bug', }, ], }); @@ -235,11 +245,11 @@ describe('create release issue', () => { }, commits: [ { - hash: 'abcdefg', + hash: 'b2501882', type: 'chore', lang: 'javascript', message: 'update devDevpendencies', - raw: 'abcdefg chore(javascript): update devDevpendencies', + raw: 'b2501882 chore(javascript): update devDevpendencies', }, ], }); diff --git a/scripts/release/create-release-issue.ts b/scripts/release/create-release-issue.ts index 2fe92b3ea2..732330a5e8 100755 --- a/scripts/release/create-release-issue.ts +++ b/scripts/release/create-release-issue.ts @@ -58,8 +58,9 @@ export function getVersionChangesText(versions: Versions): string { } export function parseCommit(commit: string): Commit { - const hash = commit.slice(0, 7); - let message = commit.slice(8); + const LENGTH_SHA1 = 8; + const hash = commit.slice(0, LENGTH_SHA1); + let message = commit.slice(LENGTH_SHA1 + 1); let type = message.slice(0, message.indexOf(':')); const matchResult = type.match(/(.+)\((.+)\)/); if (!matchResult) { From d62d6ff7e997452971d00065e6065326e9108c3f Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Thu, 24 Mar 2022 18:11:04 +0100 Subject: [PATCH 2/2] Update create-release-issue.test.ts --- scripts/release/__tests__/create-release-issue.test.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/release/__tests__/create-release-issue.test.ts b/scripts/release/__tests__/create-release-issue.test.ts index ba1c9edb25..cd5448a9ce 100644 --- a/scripts/release/__tests__/create-release-issue.test.ts +++ b/scripts/release/__tests__/create-release-issue.test.ts @@ -38,16 +38,6 @@ describe('create release issue', () => { }); }); - it('asdfa', () => { - expect(parseCommit(`5b70cadc feat(java): CTS APIC-253 (#102)`)).toEqual({ - hash: '5b70cadc', - lang: 'java', - message: 'CTS APIC-253 (#102)', - raw: '5b70cadc feat(java): CTS APIC-253 (#102)', - type: 'feat', - }); - }); - it('generates text for version changes', () => { expect( getVersionChangesText({