forked from ualbertalib/pushmi_pullyu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dangerfile
22 lines (18 loc) · 953 Bytes
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Make sure non-trivial amounts of code changes come with corresponding tests
has_app_changes = !git.modified_files.grep(/lib/).empty?
has_spec_changes = !git.modified_files.grep(/spec/).empty?
if git.lines_of_code > 50 && has_app_changes && !has_spec_changes
warn('There are code changes, but no corresponding tests. '\
'Please include tests if this PR introduces any modifications in '\
'behavior.',
sticky: false)
end
# Mainly to encourage writing up some reasoning about the PR, rather than
# just leaving a title
warn('Please add a detailed summary in the description.') if github.pr_body.length < 5
# Ensure a clean commits history
if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}'/ }
warn 'Please rebase to get rid of the merge commits in this PR'
end
# Warn when there is a big PR
warn('This PR is too big! Consider breaking it down into smaller PRs.') if git.lines_of_code > 500