Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe get compare links #1194

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions .github/scripts/generate-release-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ type Commits = Await<ReturnType<Octokit["rest"]["repos"]["compareCommits"]>>["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
Expand All @@ -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 ""
Expand Down Expand Up @@ -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),
}));
Expand Down
Loading