pre-upload: Skip revbump check for profiles paths

If a CL combines a profile update (like make.defaults) for an overlay
with an ebuild change to the files/ directory a confusing error message
comes out from the repo upload step. For example, uploading CL:2446471
causes the check to complain that the ebuild needs a manual revbump when
it really doesn't. This is because the hook is checking all paths in the
commit, including ones for the overlay's 'make.defaults'. Skip out on
paths that have '/profiles/' in them so that the revbump logic doesn't
get confused and lead developers astray.

TEST=Try to upload CL:2446471 and see it doesn't complain anymore

Change-Id: I1cffc6592e81a28d922481a704fa4e1e699919b0
Reviewed-by: Chris McDonald <>
Reviewed-by: Jack Rosenthal <>
Commit-Queue: Stephen Boyd <>
Tested-by: Stephen Boyd <>
diff --git a/ b/
index ce994f5..26b0a7e 100755
--- a/
+++ b/
@@ -19,6 +19,7 @@
 import functools
 import json
 import os
+import pathlib
 import re
 import sys
 import stat
@@ -1047,14 +1048,27 @@
       return obj.dst_file
+  def AllowedPath(obj):
+    allowed_files = {'ChangeLog', 'Manifest', 'metadata.xml'}
+    allowed_directories = {'profiles'}
+    affected = pathlib.Path(FinalName(obj))
+    if in allowed_files:
+      return True
+    for directory in allowed_directories:
+      if directory in
+        return True
+    return False
   affected_path_objs = _get_affected_files(
       commit, include_deletes=True, include_symlinks=True, relative=True,
-  # Don't yell about changes to allowed files...
-  allowlist = {'ChangeLog', 'Manifest', 'metadata.xml'}
+  # Don't yell about changes to allowed files or directories...
   affected_path_objs = [x for x in affected_path_objs
-                        if os.path.basename(FinalName(x)) not in allowlist]
+                        if not AllowedPath(x)]
   if not affected_path_objs:
     return None
diff --git a/ b/
index ccd0474..4a98523 100755
--- a/
+++ b/
@@ -1726,6 +1726,15 @@
     osutils.WriteFile(ebuild_9999_file, 'fake')
     self.assertAccepted([DiffEntry(src_file='c/p/files/f', status='M')])
+  def testModifiedFilesAndProfilesWith9999(self):
+    """Accept changes in files/ with a parent 9999 ebuild and profile change"""
+    ebuild_9999_file = os.path.join(self.tempdir, 'c/p/p-9999.ebuild')
+    os.makedirs(os.path.dirname(ebuild_9999_file))
+    osutils.WriteFile(ebuild_9999_file, 'fake')
+    self.assertAccepted([
+        DiffEntry(src_file='c/p/files/f', status='M'),
+        DiffEntry(src_file='c/profiles/base/make.defaults', status='M')])
 class DirectMainTest(PreUploadTestCase, cros_test_lib.TempDirTestCase):
   """Tests for direct_main()"""