Skip to content

Commit

Permalink
Attempt to fix danger (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Jun 3, 2021
1 parent b492d45 commit f60e3d7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,27 @@ async function checkChangelog() {
const changelogFile = "CHANGELOG.md";

// Check if skipped
const skipChangelog =
danger.github && (danger.github.pr.body + "").includes("#skip-changelog");

const skipChangelog = danger.github && (danger.github.pr.body + "").includes("#skip-changelog");
if (skipChangelog) {
return;
}

// Check if current PR has an entry in changelog
const changelogContents = await danger.github.utils.fileContents(
changelogFile
);

const hasChangelogEntry = RegExp(`#${danger.github.pr.number}\\b`).test(
changelogContents
);
const changelogContents = await danger.github.utils.fileContents(changelogFile);

const hasChangelogEntry = RegExp(`#${danger.github.pr.number}\\b`).test(changelogContents);
if (hasChangelogEntry) {
return;
}

// Short-circuit if lacking permissions
const hasCommentPermission = danger.github.pr.head.repo.git_url == danger.github.pr.base.repo.git_url;
if (!hasCommentPermission) {
console.log("Please consider adding a changelog entry for the next release.");
process.exitCode = 1;
return;
}

// Report missing changelog entry
fail(
"Please consider adding a changelog entry for the next release.",
Expand Down

0 comments on commit f60e3d7

Please sign in to comment.