Skip to content

Commit f932b26

Browse files
authored
[danger] Don't check changelogs on non-source changes (#4115)
* Only check changelogs on PRs that modify objc/objc++ source * Fix trailing whitespace * Fix style and add swift files to changelog check * Fix trailing whitespace
1 parent d8751b5 commit f932b26

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

Dangerfile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# Taken from samdmarshall/danger
55
def didModify(files_array)
66
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)
89
return true
910
end
1011
end
@@ -93,11 +94,30 @@ has_license_changes = didModify(["LICENSE"])
9394
@has_googleutilities_changes = hasChangesIn("GoogleUtilities/")
9495
@has_zipbuilder_changes = hasChangesIn("ZipBuilder/")
9596

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+
96111
### Actions
97112

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
101121
end
102122

103123
# Error on license edits

0 commit comments

Comments
 (0)