Commit 6215c79a authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

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 <ehmaldonado@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@google.com>
Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 5da394f8
......@@ -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 <project>/<bucket>.')
def _parse_bucket(raw_bucket):
legacy = True
project = bucket = None
if '/' in raw_bucket:
legacy = False
project, bucket = raw_bucket.split('/', 1)
# Assume luci.<project>.<bucket>.
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):
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment