hghooks: lift subdirectory restriction for try pushes by wptsync user (
bug 1436806); r=gps
MozReview-Commit-ID: P2ncVDzkww
--- a/hghooks/mozhghooks/check/prevent_wptsync_changes.py
+++ b/hghooks/mozhghooks/check/prevent_wptsync_changes.py
@@ -24,20 +24,16 @@ Illegal paths found:
{}{}
"""
ILLEGAL_REPO = """
wptsync@mozilla.com cannot push to {}
"""
-def legal_repo(path):
- return path == "integration/mozilla-inbound" or path == "try"
-
-
class WPTSyncCheck(PreTxnChangegroupCheck):
"""
Prevents changes to files outside of testing/web-platform
subdirectories for account wptsync@mozilla.com, and only allows
pushes to mozilla-inbound from among production repos.
This account is used by a two-way repository sync between
mozilla-central and w3c/web-platform-tests on GitHub.
@@ -48,29 +44,29 @@ class WPTSyncCheck(PreTxnChangegroupChec
def relevant(self):
return os.environ['USER'] == 'wptsync@mozilla.com'
def pre(self):
pass
def check(self, ctx):
- success = True
- if legal_repo(self.repo_metadata['path']):
- invalid_paths = [path for path in ctx.files()
- if not allowed_paths.match(path)]
-
- if invalid_paths:
+ success = False
+ if self.repo_metadata['path'] == 'try':
+ success = True
+ elif self.repo_metadata['path'] == 'integration/mozilla-inbound':
+ invalid_paths = [path for path in ctx.files() if not allowed_paths.match(path)]
+ if not invalid_paths:
+ success = True
+ else:
invalid_paths = set(invalid_paths)
print_banner(self.ui, 'error', INVALID_PATH_FOUND.format(
self.repo_metadata['path'],
"\n".join(item for item in sorted(invalid_paths)[:20]),
"\n..." if len(invalid_paths) > 20 else ""
))
- success = False
else:
print_banner(self.ui, 'error',
ILLEGAL_REPO.format(self.repo_metadata['path']))
- success = False
return success
def post_check(self):
return True
--- a/hghooks/tests/test-prevent-wptsync-changes.t
+++ b/hghooks/tests/test-prevent-wptsync-changes.t
@@ -3,17 +3,17 @@
$ configurehooks integration/mozilla-inbound
$ touch integration/mozilla-inbound/.hg/IS_FIREFOX_REPO
$ hg -q clone integration/mozilla-inbound client
$ cd client
$ mkdir -p testing/web-platform/tests
$ mkdir testing/web-platform/meta
$ mkdir other
-Regular user can push changes both in and out of testing/web-platform
+Regular user can push changes both in and beyond testing/web-platform
$ touch file0
$ touch other/file1
$ touch testing/web-platform/mozxbuild
$ touch testing/web-platform/meta/file3
$ touch testing/web-platform/tests/file4
$ hg -q commit -A -m initial
$ USER=someone@example.com hg push
@@ -126,91 +126,36 @@ Test pushes to try
$ rm -rf client
$ hg init try
$ configurehooks try
$ touch try/.hg/IS_FIREFOX_REPO
$ hg -q clone try client
$ cd client
$ mkdir -p testing/web-platform/tests
$ mkdir testing/web-platform/meta
+ $ mkdir -p taskcluster/ci
$ mkdir other
-wptsync user cannot push changes beyond testing/web-platform/tests or meta
+wptsync user can push changes beyond testing/web-platform on try
- $ touch file0a
+ $ touch try_task_config.json
+ $ touch taskcluster/ci/config.yml
$ touch other/file1a
$ touch testing/web-platform/moz_build
$ touch testing/web-platform/meta/file3a
$ touch testing/web-platform/tests/file4a
- $ hg -q commit -A -m mix-of-legal-illegal-changes
+ $ hg -q commit -A -m mix-of-changes
$ USER=wptsync@mozilla.com hg push
pushing to $TESTTMP/try
searching for changes
adding changesets
adding manifests
adding file changes
- added 1 changesets with 5 changes to 5 files
-
- ****************** ERROR *******************
- wptsync@mozilla.com can only make changes to
- the following paths on try:
- testing/web-platform/moz.build
- testing/web-platform/meta
- testing/web-platform/tests
-
- Illegal paths found:
- file0a
- other/file1a
- testing/web-platform/moz_build
- ********************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.mozhooks hook failed
- [255]
-
-wptsync user cannot push changes beyond testing/web-platform, multiple
-
- $ touch file1a
- $ hg -q commit -A -m illegal-changes
- $ USER=wptsync@mozilla.com hg push
- pushing to $TESTTMP/try
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 6 changes to 6 files
-
- ****************** ERROR *******************
- wptsync@mozilla.com can only make changes to
- the following paths on try:
- testing/web-platform/moz.build
- testing/web-platform/meta
- testing/web-platform/tests
-
- Illegal paths found:
- file0a
- other/file1a
- testing/web-platform/moz_build
- ********************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.mozhooks hook failed
- [255]
-
-Test legal changes for wptsync user on try
-
- $ cd ..
- $ rm -rf client
- $ hg -q clone try client
- $ cd client
- $ mkdir -p testing/web-platform/tests
- $ mkdir -p testing/web-platform/meta
+ added 1 changesets with 6 changes to 6 files
wptsync user can push changes to testing/web-platform/moz.build on try
$ touch testing/web-platform/moz.build
$ hg -q commit -A -m initial
$ USER=wptsync@mozilla.com hg push
pushing to $TESTTMP/try
searching for changes