forked from liamjbennett/sous
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDangerfile
More file actions
74 lines (60 loc) · 2.09 KB
/
Dangerfile
File metadata and controls
74 lines (60 loc) · 2.09 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# vim: ft=ruby:
#
def check_for_debug
git.diff.reject do |file|
file.path =~ /_test.go$/
end.each do |file|
file.patch.each_line do |patch_line|
if /^\+[^+].*(spew\.Pr|spew\.Du|spew.\Fp|spew\.Fd)/ =~ patch_line
fail "Debugging output: #{patch_line} (there may be others)"
return
end
end
end
end
def check_lgtm(image_url: nil, https_image_only: false)
return unless status_report[:errors].length.zero? &&
status_report[:warnings].length.zero?
markdown(<<-lgtm.gsub(%r[^[ ]*(?=\S)]m, ""))
# LGTM!
No errors, no warnings. :shipit:
lgtm
end
# BEGIN
# Sometimes it's a README fix, or something like that - which isn't relevant for
# including in a project's CHANGELOG for example
modified_app_files = git.modified_files.grep(/(?<!_test)\.go$/)
modified_app_files = modified_app_files.find_all do |file|
diff = git.diff_for_file(file)
interesting_lines = diff.patch.lines[5..-1]
if !interesting_lines.nil?
significant_lines = interesting_lines.grep_v(%r{^(?: |[+-]\s*(?://|$)|@@)})
!significant_lines.empty?
else
false
end
end
app_changed = !modified_app_files.empty?
declared_trivial = github.pr_title.include? "#trivial" || !app_changed
# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
warn("PR is classed as Work in Progress") if github.pr_title.include? "WIP"
# Warn when there is a big PR
warn("Big PR: #{git.lines_of_code} lines of code changed") if git.lines_of_code > 500
if !git.modified_files.include?("CHANGELOG.md") && (app_changed && !declared_trivial)
fail("Please include a CHANGELOG entry.", sticky: false)
end
full_prose = true
if full_prose
prose.lint_files "docs/*.md"
else
markdown_files = (modified_files + added_files).select do |line|
line.start_with?("_posts") && (line.end_with?(".markdown") || line.end_with?(".md"))
end
# will check any .markdown files in this PR with proselint
proselint.lint_files markdown_files
end
if !(prose.mdspell_installed? and prose.proselint_installed?)
message "mdspell or proselint not available - prose not linted"
end
check_lgtm
check_for_debug