Skip to content

Commit

Permalink
fix: ignore unreachable PRs when formatting changelogs (#2861)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Jul 30, 2024
1 parent 16ee1bf commit 6ba4fc9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .changeset/twenty-donuts-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

fix: ignore unreachable PRs when formatting changelogs
13 changes: 11 additions & 2 deletions scripts/changeset/get-full-changelog.mts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const prTypes = ["feat", "fix", "refactor", "chore", "docs"];
async function getChangelogInfo(
octokit: Octokit,
changeset: NewChangeset,
): Promise<ChangelogInfo> {
): Promise<ChangelogInfo | undefined> {
const changesetCommit = execSync(
`git log -n 1 --diff-filter=A --oneline --pretty=format:%H -- ${join(
process.cwd(),
Expand All @@ -50,6 +50,15 @@ async function getChangelogInfo(
pull_number: prNo!,
});

/**
* There are special cases that follow a different flow.
* e.g. https://github.com/FuelLabs/fuels-ts/commit/16ee1bfe66733551d00f0a76c21e8a09ea33006f.
* They should be ignored in the changelogs.
*/
if (title === undefined) {
return undefined;
}

const prType = title.replace(/(\w+).*/, "$1"); // chore!: add something -> chore
const isBreaking = title.includes(`${prType}!`);

Expand Down Expand Up @@ -107,7 +116,7 @@ async function getChangelogs(octokit: Octokit, changesets: NewChangeset[]) {
),
);

return changelogs.sort(sortChangelogsByPrType);
return changelogs.filter((c) => c !== undefined).sort(sortChangelogsByPrType);
}

function mapPrTypeToTitle(prType: string) {
Expand Down

0 comments on commit 6ba4fc9

Please sign in to comment.