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

Attempt to fix danger #1039

Merged
merged 3 commits into from
Jun 3, 2021
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
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