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.
BUG=None
TEST=Try to upload CL:2446471 and see it doesn't complain anymore
Change-Id: I1cffc6592e81a28d922481a704fa4e1e699919b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/repohooks/+/2473371
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Stephen Boyd <swboyd@chromium.org>
Tested-by: Stephen Boyd <swboyd@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index ce994f5..26b0a7e 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -19,6 +19,7 @@
import functools
import json
import os
+import pathlib
import re
import sys
import stat
@@ -1047,14 +1048,27 @@
else:
return obj.dst_file
+ def AllowedPath(obj):
+ allowed_files = {'ChangeLog', 'Manifest', 'metadata.xml'}
+ allowed_directories = {'profiles'}
+
+ affected = pathlib.Path(FinalName(obj))
+ if affected.name in allowed_files:
+ return True
+
+ for directory in allowed_directories:
+ if directory in affected.parts:
+ return True
+
+ return False
+
affected_path_objs = _get_affected_files(
commit, include_deletes=True, include_symlinks=True, relative=True,
full_details=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/pre-upload_unittest.py b/pre-upload_unittest.py
index ccd0474..4a98523 100755
--- a/pre-upload_unittest.py
+++ b/pre-upload_unittest.py
@@ -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()"""