Skip to content

Commit af879d5

Browse files
committed
chore(ci): fix commit parsing logic
1 parent f2ea49c commit af879d5

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ describe('create release issue', () => {
2626
});
2727
});
2828

29+
it('parses commit with shorter commit hash', () => {
30+
expect(
31+
parseCommit(
32+
`7cd51e2 fix(javascript): keep comments and jsdoc in build (#307)`
33+
)
34+
).toEqual({
35+
hash: '7cd51e2',
36+
lang: 'javascript',
37+
message: 'keep comments and jsdoc in build (#307)',
38+
raw: '7cd51e2 fix(javascript): keep comments and jsdoc in build (#307)',
39+
type: 'fix',
40+
});
41+
});
42+
2943
it('returns error when language scope is missing', () => {
3044
expect(parseCommit(`b2501882 fix: fix the thing`)).toEqual({
3145
error: 'missing-language-scope',

scripts/release/create-release-issue.ts

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

6060
export function parseCommit(commit: string): Commit {
61-
const LENGTH_SHA1 = 8;
62-
const hash = commit.slice(0, LENGTH_SHA1);
63-
let message = commit.slice(LENGTH_SHA1 + 1);
61+
const hash = commit.split(' ')[0];
62+
let message = commit.split(' ').slice(1).join(' ');
6463
let type = message.slice(0, message.indexOf(':'));
6564
const matchResult = type.match(/(.+)\((.+)\)/);
6665
if (!matchResult) {
@@ -179,6 +178,13 @@ async function createReleaseIssue(): Promise<void> {
179178
const commitsWithUnknownLanguageScope: string[] = [];
180179
const commitsWithoutLanguageScope: string[] = [];
181180

181+
// Remove the local tag, and fetch it from the remote.
182+
// We move the `released` tag as we release, so we need to make it up-to-date.
183+
await run(`git tag -d ${RELEASED_TAG}`);
184+
await run(
185+
`git fetch origin refs/tags/${RELEASED_TAG}:refs/tags/${RELEASED_TAG}`
186+
);
187+
182188
// Reading commits since last release
183189
const latestCommits = (
184190
await run(`git log --oneline ${RELEASED_TAG}..${MAIN_BRANCH}`)

scripts/release/process-release.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ async function processRelease(): Promise<void> {
269269
await run(`git push`);
270270

271271
// remove old `released` tag
272-
await run(`git fetch origin refs/tags/released:refs/tags/released`);
272+
await run(
273+
`git fetch origin refs/tags/${RELEASED_TAG}:refs/tags/${RELEASED_TAG}`
274+
);
273275
await run(`git tag -d ${RELEASED_TAG}`);
274276
await run(`git push --delete origin ${RELEASED_TAG}`);
275277

0 commit comments

Comments
 (0)