forked from mozilla-mobile/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dangerfile
41 lines (32 loc) · 1.53 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
34
35
36
37
38
39
40
41
# Add a link to the Bugzilla bug
# for debugging uncomment out these 2 lines
# require 'pry'
# binding.pry
# Run swiftlint
swiftlint.lint_files
# Localized Strings check
changedFiles = (git.added_files + git.modified_files).select{|file| file.end_with?(".swift")}
changedFiles.select{|file| file != "Client/Frontend/Strings.swift" }.each do |changed_file|
addedLines = git.diff_for_file(changed_file).patch.lines.select{ |line| line.start_with?("+") }
if addedLines.select{ |line| line.include?("NSLocalizedString") }.count != 0
warn("NSLocalizedString should only be added to Strings.swift")
break # We only need to show the warning once
end
end
# Add a friendly reminder for Sentry
changedFiles.each do |changed_file|
addedLines = git.diff_for_file(changed_file).patch.lines.select{ |line| line.start_with?("+") }
if addedLines.select{ |line| line.include?("Sentry.shared.send") }.count != 0
markdown("### Sentry check list")
markdown("- [ ] I understand that only .fatal events will be reported on release")
markdown("- [ ] The message param contains a string that will not create multiple events")
break
end
end
# Fail if diff contains !try or as!
changedFiles.each do |changed_file|
# filter out only the lines that were added
addedLines = git.diff_for_file(changed_file).patch.lines.select{ |line| line.start_with?("+") }
fail("No new force try! or as!") if addedLines.select{ |line| (line.include?("as!") || line.include?("try!")) }.count != 0
end
#limit the number of new lines added to BVC to less than 10