-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from capistrano/capistrano-danger
Use shared capistrano/danger Dangerfile
- Loading branch information
Showing
1 changed file
with
1 addition
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1 @@ | ||
# Adapted from https://github.com/ruby-grape/danger/blob/master/Dangerfile | ||
# Q: What is a Dangerfile, anyway? A: See http://danger.systems/ | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Additional pull request data | ||
# ------------------------------------------------------------------------------ | ||
project_name = github.pr_json["base"]["repo"]["name"] | ||
pr_number = github.pr_json["number"] | ||
pr_url = github.pr_json["_links"]["html"]["href"] | ||
|
||
# ------------------------------------------------------------------------------ | ||
# What changed? | ||
# ------------------------------------------------------------------------------ | ||
has_lib_changes = !git.modified_files.grep(/^lib/).empty? | ||
has_changelog_changes = git.modified_files.include?("CHANGELOG.md") | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Have you updated CHANGELOG.md? | ||
# ------------------------------------------------------------------------------ | ||
if !has_changelog_changes && has_lib_changes | ||
markdown <<-MARKDOWN | ||
Here's an example of a CHANGELOG.md entry (place it immediately under the `* Your contribution here!` line): | ||
```markdown | ||
* [##{pr_number}](#{pr_url}): #{github.pr_title} - [@#{github.pr_author}](https://github.com/#{github.pr_author}). | ||
``` | ||
MARKDOWN | ||
warn("Please update CHANGELOG.md with a description of your changes. "\ | ||
"If this PR is not a user-facing change (e.g. just refactoring), "\ | ||
"you can disregard this.", :sticky => false) | ||
end | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Did you remove the CHANGELOG's "Your contribution here!" line? | ||
# ------------------------------------------------------------------------------ | ||
if has_changelog_changes | ||
unless IO.read("CHANGELOG.md") =~ /^\* Your contribution here/i | ||
fail( | ||
"Please put the `* Your contribution here!` line back into CHANGELOG.md.", | ||
:sticky => false | ||
) | ||
end | ||
end | ||
danger.import_dangerfile(github: "capistrano/danger") |