From 4f1b31319f4a96df7f2028faa5272d81a7cba4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Sat, 2 Mar 2024 14:11:22 +0100 Subject: [PATCH] Safe get compare links (#1194) --- .github/scripts/generate-release-body.ts | 27 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/scripts/generate-release-body.ts b/.github/scripts/generate-release-body.ts index 67d9765261..6bab42c93b 100644 --- a/.github/scripts/generate-release-body.ts +++ b/.github/scripts/generate-release-body.ts @@ -10,9 +10,15 @@ type Commits = Await>["da function getCompareLink(packageName: string, previousTag: string, newTag: string) { // Previous - const previousPackage = execSync( - `git show ${previousTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'` - ).toString(); + let previousPackage: string; + try { + previousPackage = execSync( + `git show ${previousTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'` + ).toString(); + } catch (error) { + console.error('An error occurred while executing the shell command:', error); + return "" + } const previousCommitTmp = /#([0-9a-f]*)/g.exec(previousPackage); if (previousCommitTmp == null) { // regexp didn't match @@ -27,9 +33,16 @@ function getCompareLink(packageName: string, previousTag: string, newTag: string const previousRepo = previousRepoTmp[1]; // New - const newPackage = execSync( - `git show ${newTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'` - ).toString(); + let newPackage: string; + try { + newPackage = execSync( + `git show ${newTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'` + ).toString(); + } catch (error) { + console.error('An error occurred while executing the shell command:', error); + return "" + } + const newCommitTmp = /#([0-9a-f]*)/g.exec(newPackage) if (newCommitTmp == null) { return "" @@ -255,7 +268,7 @@ async function main() { getRuntimeInfo(argv["srtool-report-folder"], runtimeName) ); - const moduleLinks = ["substrate", "polkadot", "cumulus", "frontier"].map((repoName) => ({ + const moduleLinks = ["polkadot-sdk", "frontier"].map((repoName) => ({ name: repoName, link: getCompareLink(repoName, previousTag, newTag), }));