Skip to content

Commit 4f1b313

Browse files
authored
Safe get compare links (#1194)
1 parent 4ffdf07 commit 4f1b313

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

.github/scripts/generate-release-body.ts

+20-7
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ type Commits = Await<ReturnType<Octokit["rest"]["repos"]["compareCommits"]>>["da
1010

1111
function getCompareLink(packageName: string, previousTag: string, newTag: string) {
1212
// Previous
13-
const previousPackage = execSync(
14-
`git show ${previousTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
15-
).toString();
13+
let previousPackage: string;
14+
try {
15+
previousPackage = execSync(
16+
`git show ${previousTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
17+
).toString();
18+
} catch (error) {
19+
console.error('An error occurred while executing the shell command:', error);
20+
return ""
21+
}
1622

1723
const previousCommitTmp = /#([0-9a-f]*)/g.exec(previousPackage);
1824
if (previousCommitTmp == null) { // regexp didn't match
@@ -27,9 +33,16 @@ function getCompareLink(packageName: string, previousTag: string, newTag: string
2733
const previousRepo = previousRepoTmp[1];
2834

2935
// New
30-
const newPackage = execSync(
31-
`git show ${newTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
32-
).toString();
36+
let newPackage: string;
37+
try {
38+
newPackage = execSync(
39+
`git show ${newTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
40+
).toString();
41+
} catch (error) {
42+
console.error('An error occurred while executing the shell command:', error);
43+
return ""
44+
}
45+
3346
const newCommitTmp = /#([0-9a-f]*)/g.exec(newPackage)
3447
if (newCommitTmp == null) {
3548
return ""
@@ -255,7 +268,7 @@ async function main() {
255268
getRuntimeInfo(argv["srtool-report-folder"], runtimeName)
256269
);
257270

258-
const moduleLinks = ["substrate", "polkadot", "cumulus", "frontier"].map((repoName) => ({
271+
const moduleLinks = ["polkadot-sdk", "frontier"].map((repoName) => ({
259272
name: repoName,
260273
link: getCompareLink(repoName, previousTag, newTag),
261274
}));

0 commit comments

Comments
 (0)