Skip to content

Commit

Permalink
In the rare case that the first 7 characters of a git sha contains on…
Browse files Browse the repository at this point in the history
…ly numbers and begins with 0, SemVer will reject the canaryIdentifier. In such cases, make sure we include enough of the sha to get a letter.
  • Loading branch information
MichaelRyanWebber committed Apr 2, 2024
1 parent 6f694fe commit d511a2e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,11 @@ export default class Auto {
}

if (!pr || !build) {
canaryIdentifier = `${canaryIdentifier}.${(
await this.git.getSha(true)
).slice(0, 7)}`;
const sha = await this.git.getSha();
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 d511a2e

Please sign in to comment.