|
4 | 4 | # Taken from samdmarshall/danger
|
5 | 5 | def didModify(files_array)
|
6 | 6 | files_array.each do |file_name|
|
7 |
| - if git.modified_files.include?(file_name) || git.deleted_files.include?(file_name) |
| 7 | + if git.modified_files.include?(file_name) || |
| 8 | + git.deleted_files.include?(file_name) |
8 | 9 | return true
|
9 | 10 | end
|
10 | 11 | end
|
@@ -93,11 +94,30 @@ has_license_changes = didModify(["LICENSE"])
|
93 | 94 | @has_googleutilities_changes = hasChangesIn("GoogleUtilities/")
|
94 | 95 | @has_zipbuilder_changes = hasChangesIn("ZipBuilder/")
|
95 | 96 |
|
| 97 | +# A FileList containing ObjC, ObjC++ or C++ changes. |
| 98 | +sdk_changes = (git.modified_files + |
| 99 | + git.added_files + |
| 100 | + git.deleted_files).select do |line| |
| 101 | + line.end_with?(".h") || |
| 102 | + line.end_with?(".m") || |
| 103 | + line.end_with?(".mm") || |
| 104 | + line.end_with?(".cc") || |
| 105 | + line.end_with?(".swift") |
| 106 | +end |
| 107 | + |
| 108 | +# Whether or not the PR has modified SDK source files. |
| 109 | +has_sdk_changes = sdk_changes.empty? |
| 110 | + |
96 | 111 | ### Actions
|
97 | 112 |
|
98 |
| -# Warn if a changelog is left out on a non-trivial PR |
99 |
| -if !has_changelog_changes && !declared_trivial |
100 |
| - warn("Did you forget to add a changelog entry? (Add `#no-changelog` to the PR description to silence this warning.)") |
| 113 | +# Warn if a changelog is left out on a non-trivial PR that has modified |
| 114 | +# SDK source files (podspec, markdown, etc changes are excluded). |
| 115 | +if has_sdk_changes |
| 116 | + if !has_changelog_changes && !declared_trivial |
| 117 | + warning = "Did you forget to add a changelog entry? (Add #no-changelog"\ |
| 118 | + " to the PR description to silence this warning.)" |
| 119 | + warn(warning) |
| 120 | + end |
101 | 121 | end
|
102 | 122 |
|
103 | 123 | # Error on license edits
|
|
0 commit comments