From d511a2e6e333e76a16e5f611d035e810a25308d2 Mon Sep 17 00:00:00 2001 From: michael webber Date: Tue, 2 Apr 2024 00:03:27 -0400 Subject: [PATCH 1/2] 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}`; From c214a53c4a1f93860863bfc8404d4fed787fdbc9 Mon Sep 17 00:00:00 2001 From: michael webber Date: Tue, 2 Apr 2024 17:09:39 -0400 Subject: [PATCH 2/2] add comment --- packages/core/src/auto.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts index e83318454..c7253ebca 100644 --- a/packages/core/src/auto.ts +++ b/packages/core/src/auto.ts @@ -1311,6 +1311,9 @@ export default class Auto { if (!pr || !build) { 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;