From d511a2e6e333e76a16e5f611d035e810a25308d2 Mon Sep 17 00:00:00 2001 From: michael webber Date: Tue, 2 Apr 2024 00:03:27 -0400 Subject: [PATCH] In the rare case that the first 7 characters of a git sha contains only 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. --- packages/core/src/auto.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts index b52a3905b..e83318454 100644 --- a/packages/core/src/auto.ts +++ b/packages/core/src/auto.ts @@ -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}`;