Skip to content

Commit 7668a85

Browse files
authored
Add new danger check (#10338)
* Add new danger check * test warning * Revert "test warning" This reverts commit ec05690. * upgrade to error
1 parent 5fc7749 commit 7668a85

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Dangerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ def hasChangesIn(paths)
2424
return false
2525
end
2626

27+
# Determine if any new files were added to paths matching any of the
28+
# path patterns provided.
29+
def hasAdditionsIn(paths)
30+
path_array = Array(paths)
31+
path_array.each do |dir|
32+
if !git.added_files.grep(/#{dir}/).empty?
33+
return true
34+
end
35+
end
36+
return false
37+
end
38+
2739
# Adds the provided labels to the current PR.
2840
def addLabels(label_array)
2941
issue_number = github.pr_json["number"]
@@ -118,6 +130,8 @@ has_license_changes = didModify(["LICENSE"])
118130
@has_storage_changes = hasChangesIn("FirebaseStorage")
119131

120132
@has_releasetooling_changes = hasChangesIn("ReleaseTooling/")
133+
@has_public_additions = hasAdditionsIn("Public/")
134+
@has_umbrella_changes = hasChangesIn("Firebase*.h")
121135

122136
# Convenient flag for all API changes.
123137
@has_api_changes = @has_abtesting_api_changes ||
@@ -164,6 +178,14 @@ if has_sdk_changes
164178
end
165179
end
166180

181+
# Warn if a new public header file is added but no umbrella header changes
182+
# are detected. Prevents regression of #10301
183+
if @has_public_additions && !@has_umbrella_changes
184+
error = "New public headers were added, "\
185+
"did you remember to add them to the umbrella header?"
186+
fail(error)
187+
end
188+
167189
# Error on license edits
168190
fail("LICENSE changes are explicitly disallowed.") if has_license_changes
169191

0 commit comments

Comments
 (0)