Skip to content

Commit 666e239

Browse files
Merge pull request #2448 from MichaelRyanWebber/fix/canary-id-unlucky-sha
Fix rare issue with canary id from git sha
2 parents 6f694fe + c214a53 commit 666e239

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/core/src/auto.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,14 @@ export default class Auto {
13101310
}
13111311

13121312
if (!pr || !build) {
1313-
canaryIdentifier = `${canaryIdentifier}.${(
1314-
await this.git.getSha(true)
1315-
).slice(0, 7)}`;
1313+
const sha = await this.git.getSha();
1314+
// If the commit sha is a 7 digit number starting with zero
1315+
// SemVer will reject the version. Include enough of the sha
1316+
// to include at least one letter in that case.
1317+
const endIndex = /^0\d{6}/.test(sha) ?
1318+
sha.search(/[a-zA-Z]/) + 1
1319+
: 7;
1320+
canaryIdentifier = `${canaryIdentifier}.${sha.slice(0, endIndex)}`;
13161321
}
13171322

13181323
canaryIdentifier = `-canary${canaryIdentifier}`;

0 commit comments

Comments
 (0)