Skip to content

Commit

Permalink
chore(ci): parse commits correctly (#294)
Browse files Browse the repository at this point in the history
* chore(ci): parse commits correctly

* Update create-release-issue.test.ts
  • Loading branch information
eunjae-lee authored Mar 25, 2022
1 parent 8650fe4 commit 7f0fcae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
30 changes: 15 additions & 15 deletions scripts/release/__tests__/create-release-issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ 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',
});
});
Expand Down Expand Up @@ -125,11 +125,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)',
},
],
});
Expand All @@ -152,11 +152,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',
},
],
});
Expand All @@ -179,11 +179,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',
},
],
});
Expand All @@ -206,11 +206,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',
},
],
});
Expand All @@ -235,11 +235,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',
},
],
});
Expand Down
5 changes: 3 additions & 2 deletions scripts/release/create-release-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7f0fcae

Please sign in to comment.