瀏覽代碼

Add new danger check (#10338)

* Add new danger check

* test warning

* Revert "test warning"

This reverts commit ec0569079f8cd603c077dd927f2939acf67b7f7e.

* upgrade to error
Morgan Chen 3 年之前
父節點
當前提交
7668a85a43
共有 1 個文件被更改,包括 22 次插入0 次删除
  1. 22 0
      Dangerfile

+ 22 - 0
Dangerfile

@@ -24,6 +24,18 @@ def hasChangesIn(paths)
   return false
 end
 
+# Determine if any new files were added to paths matching any of the
+# path patterns provided.
+def hasAdditionsIn(paths)
+  path_array = Array(paths)
+  path_array.each do |dir|
+    if !git.added_files.grep(/#{dir}/).empty?
+      return true
+    end
+  end
+  return false
+end
+
 # Adds the provided labels to the current PR.
 def addLabels(label_array)
   issue_number = github.pr_json["number"]
@@ -118,6 +130,8 @@ has_license_changes = didModify(["LICENSE"])
 @has_storage_changes = hasChangesIn("FirebaseStorage")
 
 @has_releasetooling_changes = hasChangesIn("ReleaseTooling/")
+@has_public_additions = hasAdditionsIn("Public/")
+@has_umbrella_changes = hasChangesIn("Firebase*.h")
 
 # Convenient flag for all API changes.
 @has_api_changes = @has_abtesting_api_changes ||
@@ -164,6 +178,14 @@ if has_sdk_changes
   end
 end
 
+# Warn if a new public header file is added but no umbrella header changes
+# are detected. Prevents regression of #10301
+if @has_public_additions && !@has_umbrella_changes
+  error = "New public headers were added, "\
+      "did you remember to add them to the umbrella header?"
+  fail(error)
+end
+
 # Error on license edits
 fail("LICENSE changes are explicitly disallowed.") if has_license_changes