Support --target_branch=refs/meta/config branch

This simplifies the administration of repositories which is currently
done via the Gerrit UI instead of the CLI.

Bug: None
Change-Id: I0af3d77fb611e0c89dc455a5a215129b5c51c5ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5472843
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Alexander Schulze <alexschulze@chromium.org>
changes/43/5472843/4
Alexander Schulze 1 year ago committed by LUCI CQ
parent 6ba67afd6f
commit b0e2e28a95

@ -1320,7 +1320,8 @@ class Changelist(object):
self.branchref = branchref
if self.branchref:
assert branchref.startswith(('refs/heads/', 'refs/branch-heads/'))
assert (branchref.startswith(('refs/heads/', 'refs/branch-heads/'))
or branchref == 'refs/meta/config')
self.branch = scm.GIT.ShortBranchName(self.branchref)
else:
self.branch = None

@ -260,6 +260,30 @@ class TestGitClBasic(unittest.TestCase):
self.assertFalse(hasattr(options, 'force'))
self.assertFalse(hasattr(options, 'edit_description'))
def test_upload_to_meta_config_branch_no_retry(self):
m = mock.patch('git_cl.Changelist._CMDUploadChange',
side_effect=[git_cl.GitPushError(), None]).start()
mock.patch('git_cl.Changelist.GetRemoteBranch',
return_value=('foo', 'bar')).start()
mock.patch('git_cl.Changelist.GetGerritProject',
return_value='foo').start()
mock.patch('git_cl.gerrit_util.GetProjectHead',
return_value='refs/heads/main').start()
cl = git_cl.Changelist()
options = optparse.Values()
options.target_branch = 'refs/meta/config'
with self.assertRaises(SystemExitMock):
cl.CMDUploadChange(options, [], 'foo',
git_cl.ChangeDescription('bar'))
# ensure upload is called once
self.assertEqual(len(m.mock_calls), 1)
sys.exit.assert_called_once_with(1)
# option not set as retry didn't happen
self.assertFalse(hasattr(options, 'force'))
self.assertFalse(hasattr(options, 'edit_description'))
def test_upload_to_old_default_still_active(self):
m = mock.patch('git_cl.Changelist._CMDUploadChange',
side_effect=[git_cl.GitPushError(), None]).start()

Loading…
Cancel
Save