From 6215c79a8c5b1613ca043a327dcc76d4f31b7473 Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Thu, 3 Oct 2019 21:59:05 +0000 Subject: [PATCH] git-cl: Better warning message for legacy buckets. Bug: 976104 Change-Id: Ide06f73faf7a9ce6aa2d7f47deffc0c505dcdb14 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1835017 Auto-Submit: Edward Lesmes Reviewed-by: Andrii Shyshkalov Reviewed-by: Anthony Polito Commit-Queue: Edward Lesmes --- git_cl.py | 26 +++++++++++++++----------- tests/git_cl_test.py | 5 +++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/git_cl.py b/git_cl.py index 30088cca3a..7c0b703a33 100755 --- a/git_cl.py +++ b/git_cl.py @@ -423,19 +423,23 @@ def _get_bucket_map(changelist, options, option_parser): 'Please specify the bucket, e.g. "-B luci.chromium.try".') -def _parse_bucket(bucket): - if '/' in bucket: - return tuple(bucket.split('/', 1)) - # Legacy buckets. - print('WARNING Please specify buckets as /.') +def _parse_bucket(raw_bucket): + legacy = True + project = bucket = None + if '/' in raw_bucket: + legacy = False + project, bucket = raw_bucket.split('/', 1) # Assume luci... - if bucket.startswith('luci.'): - return tuple(bucket[len('luci.'):].split('.', 1)) + elif raw_bucket.startswith('luci.'): + project, bucket = raw_bucket[len('luci.'):].split('.', 1) # Otherwise, assume prefix is also the project name. - if '.' in bucket: - project = bucket.split('.')[0] - return project, bucket - return None, None + elif '.' in raw_bucket: + project = raw_bucket.split('.')[0] + bucket = raw_bucket + # Legacy buckets. + if legacy: + print('WARNING Please use %s/%s to specify the bucket.' % (project, bucket)) + return project, bucket def _trigger_try_jobs(auth_config, changelist, buckets, options, patchset): diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index d3b083eeec..5f191a1b29 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -3321,8 +3321,9 @@ class CMDTryTestCase(unittest.TestCase): self.assertEqual( test_case['result'], git_cl._parse_bucket(test_case['bucket'])) if test_case.get('has_warning'): - self.assertIn( - 'WARNING Please specify buckets', git_cl.sys.stdout.getvalue()) + expected_warning = 'WARNING Please use %s/%s to specify the bucket' % ( + test_case['result']) + self.assertIn(expected_warning, git_cl.sys.stdout.getvalue()) class CMDUploadTestCase(unittest.TestCase):