Skip to content

Commit 7f0fcae

Browse files
authored
chore(ci): parse commits correctly (#294)
* chore(ci): parse commits correctly * Update create-release-issue.test.ts
1 parent 8650fe4 commit 7f0fcae

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

scripts/release/__tests__/create-release-issue.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ describe('create release issue', () => {
1717
});
1818

1919
it('parses commit', () => {
20-
expect(parseCommit(`abcdefg fix(javascript): fix the thing`)).toEqual({
21-
hash: 'abcdefg',
20+
expect(parseCommit(`b2501882 fix(javascript): fix the thing`)).toEqual({
21+
hash: 'b2501882',
2222
lang: 'javascript',
2323
message: 'fix the thing',
24-
raw: 'abcdefg fix(javascript): fix the thing',
24+
raw: 'b2501882 fix(javascript): fix the thing',
2525
type: 'fix',
2626
});
2727
});
2828

2929
it('returns error when language scope is missing', () => {
30-
expect(parseCommit(`abcdefg fix: fix the thing`)).toEqual({
30+
expect(parseCommit(`b2501882 fix: fix the thing`)).toEqual({
3131
error: 'missing-language-scope',
3232
});
3333
});
3434

3535
it('returns error when language scope is unknown', () => {
36-
expect(parseCommit(`abcdefg fix(basic): fix the thing`)).toEqual({
36+
expect(parseCommit(`b2501882 fix(basic): fix the thing`)).toEqual({
3737
error: 'unknown-language-scope',
3838
});
3939
});
@@ -125,11 +125,11 @@ describe('create release issue', () => {
125125
},
126126
commits: [
127127
{
128-
hash: 'abcdefg',
128+
hash: 'b2501882',
129129
type: 'feat',
130130
lang: 'javascript',
131131
message: 'update the API (BREAKING CHANGE)',
132-
raw: 'abcdefg feat(javascript): update the API (BREAKING CHANGE)',
132+
raw: 'b2501882 feat(javascript): update the API (BREAKING CHANGE)',
133133
},
134134
],
135135
});
@@ -152,11 +152,11 @@ describe('create release issue', () => {
152152
},
153153
commits: [
154154
{
155-
hash: 'abcdefg',
155+
hash: 'b2501882',
156156
type: 'feat',
157157
lang: 'php',
158158
message: 'update the API',
159-
raw: 'abcdefg feat(php): update the API',
159+
raw: 'b2501882 feat(php): update the API',
160160
},
161161
],
162162
});
@@ -179,11 +179,11 @@ describe('create release issue', () => {
179179
},
180180
commits: [
181181
{
182-
hash: 'abcdefg',
182+
hash: 'b2501882',
183183
type: 'fix',
184184
lang: 'java',
185185
message: 'fix some bug',
186-
raw: 'abcdefg fix(java): fix some bug',
186+
raw: 'b2501882 fix(java): fix some bug',
187187
},
188188
],
189189
});
@@ -206,11 +206,11 @@ describe('create release issue', () => {
206206
},
207207
commits: [
208208
{
209-
hash: 'abcdefg',
209+
hash: 'b2501882',
210210
type: 'fix',
211211
lang: 'java',
212212
message: 'fix some bug',
213-
raw: 'abcdefg fix(java): fix some bug',
213+
raw: 'b2501882 fix(java): fix some bug',
214214
},
215215
],
216216
});
@@ -235,11 +235,11 @@ describe('create release issue', () => {
235235
},
236236
commits: [
237237
{
238-
hash: 'abcdefg',
238+
hash: 'b2501882',
239239
type: 'chore',
240240
lang: 'javascript',
241241
message: 'update devDevpendencies',
242-
raw: 'abcdefg chore(javascript): update devDevpendencies',
242+
raw: 'b2501882 chore(javascript): update devDevpendencies',
243243
},
244244
],
245245
});

scripts/release/create-release-issue.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ export function getVersionChangesText(versions: Versions): string {
5858
}
5959

6060
export function parseCommit(commit: string): Commit {
61-
const hash = commit.slice(0, 7);
62-
let message = commit.slice(8);
61+
const LENGTH_SHA1 = 8;
62+
const hash = commit.slice(0, LENGTH_SHA1);
63+
let message = commit.slice(LENGTH_SHA1 + 1);
6364
let type = message.slice(0, message.indexOf(':'));
6465
const matchResult = type.match(/(.+)\((.+)\)/);
6566
if (!matchResult) {

0 commit comments

Comments
 (0)