-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDangerfile
33 lines (26 loc) · 1.12 KB
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
message "Thanks @#{github.pr_author}!"
if github.pr_body.length == 0
fail "Please provide a summary in the Pull Request description."
end
if git.lines_of_code > 200
warn "Please consider breaking up this pull request."
end
#optional but please consideer adding labels
# if github.pr_labels.empty?
# warn "Please add labels to this PR."
# end
if git.deletions > git.insertions
message "🎉 Code Cleanup!"
end
# Notify of outdated dependencies
dependencyUpdatesHeader = "The following dependencies have later milestone versions:"
dependencyReportsFile = "app/build/dependencyUpdates/report.txt"
# Due to the formatting of this output file, we first check if there are any dependencies
# by looking for a `->` arrow, then we check for the relevant headers. We do this to handle a case
# where there are no app dependencies but there are Gradle dependencies.
hasDependencyUpdatesHeader = File.readlines(dependencyReportsFile).grep(/#{dependencyUpdatesHeader}/).any?
if hasDependencyUpdatesHeader
file = File.open(dependencyReportsFile, "rb").read
index = file.index(dependencyUpdatesHeader)
message file.slice(index..-1)
end