|
| 1 | +# Adapted from https://github.com/ruby-grape/danger/blob/master/Dangerfile |
| 2 | +# Q: What is a Dangerfile, anyway? A: See http://danger.systems/ |
| 3 | + |
| 4 | +# ------------------------------------------------------------------------------ |
| 5 | +# Additional pull request data |
| 6 | +# ------------------------------------------------------------------------------ |
| 7 | +project_name = github.pr_json["base"]["repo"]["name"] |
| 8 | +pr_number = github.pr_json["number"] |
| 9 | +pr_url = github.pr_json["_links"]["html"]["href"] |
| 10 | + |
| 11 | +# ------------------------------------------------------------------------------ |
| 12 | +# What changed? |
| 13 | +# ------------------------------------------------------------------------------ |
| 14 | +has_lib_changes = !git.modified_files.grep(/^lib/).empty? |
| 15 | +has_changelog_changes = git.modified_files.include?("CHANGELOG.md") |
| 16 | + |
| 17 | +# ------------------------------------------------------------------------------ |
| 18 | +# Have you updated CHANGELOG.md? |
| 19 | +# ------------------------------------------------------------------------------ |
| 20 | +if !has_changelog_changes && has_lib_changes |
| 21 | + markdown <<-MARKDOWN |
| 22 | +Here's an example of a CHANGELOG.md entry (place it immediately under the `* Your contribution here!` line): |
| 23 | +
|
| 24 | +```markdown |
| 25 | +* [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}). |
| 26 | +``` |
| 27 | +MARKDOWN |
| 28 | + warn("Please update CHANGELOG.md with a description of your changes. "\ |
| 29 | + "If this PR is not a user-facing change (e.g. just refactoring), "\ |
| 30 | + "you can disregard this.", :sticky => false) |
| 31 | +end |
| 32 | + |
| 33 | +# ------------------------------------------------------------------------------ |
| 34 | +# Did you remove the CHANGELOG's "Your contribution here!" line? |
| 35 | +# ------------------------------------------------------------------------------ |
| 36 | +if has_changelog_changes |
| 37 | + unless IO.read("CHANGELOG.md") =~ /^\* Your contribution here/i |
| 38 | + fail( |
| 39 | + "Please put the `* Your contribution here!` line back into CHANGELOG.md.", |
| 40 | + :sticky => false |
| 41 | + ) |
| 42 | + end |
| 43 | +end |
0 commit comments