Skip to content

Commit

Permalink
released plugin: handle PR versions that dont exist
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Feb 1, 2021
1 parent 24f7c32 commit 18db4df
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions plugins/released/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,38 +126,42 @@ export default class ReleasedLabelPlugin implements IPlugin {
const isPrerelease = releases.some((r) => r.data.prerelease);

if (commit.pullRequest) {
const pr = await auto.git!.getPullRequest(commit.pullRequest.number);
const branch = pr?.data.head.ref;
try {
const pr = await auto.git!.getPullRequest(commit.pullRequest.number);
const branch = pr?.data.head.ref;

if (branch && auto.config?.prereleaseBranches.includes(branch)) {
return;
}
if (branch && auto.config?.prereleaseBranches.includes(branch)) {
return;
}

if (
!this.options.includeBotPrs &&
commit.authors.some(
(author) =>
(author.name && botList.includes(author.name)) ||
(author.username && botList.includes(author.username)) ||
author.type === "Bot"
)
) {
return;
}
if (
!this.options.includeBotPrs &&
commit.authors.some(
(author) =>
(author.name && botList.includes(author.name)) ||
(author.username && botList.includes(author.username)) ||
author.type === "Bot"
)
) {
return;
}

await this.addCommentAndLabel({
auto,
prOrIssue: commit.pullRequest.number,
isPrerelease,
releases,
});
await this.addCommentAndLabel({
auto,
prOrIssue: commit.pullRequest.number,
isPrerelease,
releases,
});

pr.data.body?.split("\n").map((line) => messages.push(line));
pr.data.body?.split("\n").map((line) => messages.push(line));

const commitsInPr = await auto.git!.getCommitsForPR(
commit.pullRequest.number
);
commitsInPr.map((c) => messages.push(c.commit.message));
const commitsInPr = await auto.git!.getCommitsForPR(
commit.pullRequest.number
);
commitsInPr.map((c) => messages.push(c.commit.message));
} catch (error) {
auto.logger.verbose.log(error);
}
}

const issues = messages
Expand Down

0 comments on commit 18db4df

Please sign in to comment.