Skip to content

Commit

Permalink
Merge pull request #2448 from MichaelRyanWebber/fix/canary-id-unlucky…
Browse files Browse the repository at this point in the history
…-sha

Fix rare issue with canary id from git sha
  • Loading branch information
hipstersmoothie committed Apr 3, 2024
2 parents 6f694fe + c214a53 commit 666e239
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/core/src/auto.ts
Expand Up @@ -1310,9 +1310,14 @@ export default class Auto {
}

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

canaryIdentifier = `-canary${canaryIdentifier}`;
Expand Down

0 comments on commit 666e239

Please sign in to comment.