diff --git a/git_cl.py b/git_cl.py index 97cf55427..2f7570bc5 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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 diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 11c72e087..06f792532 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -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()