|
@@ -96,7 +96,7 @@ class ChangelistMock(object):
|
|
|
|
|
|
class GitMocks(object):
|
|
class GitMocks(object):
|
|
def __init__(self, config=None, branchref=None):
|
|
def __init__(self, config=None, branchref=None):
|
|
- self.branchref = branchref or 'refs/heads/master'
|
|
|
|
|
|
+ self.branchref = branchref or 'refs/heads/main'
|
|
self.config = config or {}
|
|
self.config = config or {}
|
|
|
|
|
|
def GetBranchRef(self, _root):
|
|
def GetBranchRef(self, _root):
|
|
@@ -265,11 +265,11 @@ class TestGitClBasic(unittest.TestCase):
|
|
mock.patch('git_cl.Changelist.GetGerritProject',
|
|
mock.patch('git_cl.Changelist.GetGerritProject',
|
|
return_value='foo').start()
|
|
return_value='foo').start()
|
|
mock.patch('git_cl.gerrit_util.GetProjectHead',
|
|
mock.patch('git_cl.gerrit_util.GetProjectHead',
|
|
- return_value='refs/heads/master').start()
|
|
|
|
|
|
+ return_value='refs/heads/main').start()
|
|
|
|
|
|
cl = git_cl.Changelist()
|
|
cl = git_cl.Changelist()
|
|
options = optparse.Values()
|
|
options = optparse.Values()
|
|
- options.target_branch = 'refs/heads/master'
|
|
|
|
|
|
+ options.target_branch = 'refs/heads/main'
|
|
with self.assertRaises(SystemExitMock):
|
|
with self.assertRaises(SystemExitMock):
|
|
cl.CMDUploadChange(options, [], 'foo', git_cl.ChangeDescription('bar'))
|
|
cl.CMDUploadChange(options, [], 'foo', git_cl.ChangeDescription('bar'))
|
|
|
|
|
|
@@ -280,27 +280,6 @@ class TestGitClBasic(unittest.TestCase):
|
|
self.assertFalse(hasattr(options, 'force'))
|
|
self.assertFalse(hasattr(options, 'force'))
|
|
self.assertFalse(hasattr(options, 'edit_description'))
|
|
self.assertFalse(hasattr(options, 'edit_description'))
|
|
|
|
|
|
- def test_upload_to_old_default_retry_on_failure(self):
|
|
|
|
- m = mock.patch('git_cl.Changelist._CMDUploadChange',
|
|
|
|
- side_effect=[git_cl.GitPushError(), None]).start()
|
|
|
|
- mock.patch('git_cl.Changelist.GetRemoteBranch',
|
|
|
|
- return_value=('foo', git_cl.DEFAULT_OLD_BRANCH)).start()
|
|
|
|
- mock.patch('git_cl.Changelist.GetGerritProject',
|
|
|
|
- return_value='foo').start()
|
|
|
|
- mock.patch('git_cl.gerrit_util.GetProjectHead',
|
|
|
|
- return_value='refs/heads/main').start()
|
|
|
|
- mock.patch('git_cl.RunGit').start()
|
|
|
|
-
|
|
|
|
- cl = git_cl.Changelist()
|
|
|
|
- options = optparse.Values()
|
|
|
|
- options.target_branch = 'refs/heads/master'
|
|
|
|
- cl.CMDUploadChange(options, [], 'foo', git_cl.ChangeDescription('bar'))
|
|
|
|
- # ensure upload is called twice
|
|
|
|
- self.assertEqual(len(m.mock_calls), 2)
|
|
|
|
- # option overrides on retry
|
|
|
|
- self.assertEqual(options.force, True)
|
|
|
|
- self.assertEqual(options.edit_description, False)
|
|
|
|
-
|
|
|
|
def test_upload_with_message_file_no_editor(self):
|
|
def test_upload_with_message_file_no_editor(self):
|
|
m = mock.patch('git_cl.ChangeDescription.prompt',
|
|
m = mock.patch('git_cl.ChangeDescription.prompt',
|
|
return_value=None).start()
|
|
return_value=None).start()
|
|
@@ -318,7 +297,7 @@ class TestGitClBasic(unittest.TestCase):
|
|
|
|
|
|
cl = git_cl.Changelist()
|
|
cl = git_cl.Changelist()
|
|
options = optparse.Values()
|
|
options = optparse.Values()
|
|
- options.target_branch = 'refs/heads/master'
|
|
|
|
|
|
+ options.target_branch = 'refs/heads/main'
|
|
options.squash = True
|
|
options.squash = True
|
|
options.edit_description = False
|
|
options.edit_description = False
|
|
options.force = False
|
|
options.force = False
|
|
@@ -334,32 +313,6 @@ class TestGitClBasic(unittest.TestCase):
|
|
cl.CMDUploadChange(options, [], 'foo', git_cl.ChangeDescription('bar'))
|
|
cl.CMDUploadChange(options, [], 'foo', git_cl.ChangeDescription('bar'))
|
|
self.assertEqual(len(m.mock_calls), 1)
|
|
self.assertEqual(len(m.mock_calls), 1)
|
|
|
|
|
|
- def test_upload_to_old_default_retry_on_rollback(self):
|
|
|
|
- """Test when default branch migration had to be rolled back to old name"""
|
|
|
|
- m = mock.patch('git_cl.Changelist._CMDUploadChange',
|
|
|
|
- side_effect=[git_cl.GitPushError(), None]).start()
|
|
|
|
- mock.patch('git_cl.Changelist.GetRemoteBranch',
|
|
|
|
- return_value=('foo', git_cl.DEFAULT_NEW_BRANCH)).start()
|
|
|
|
- mock.patch('git_cl.Changelist.GetGerritProject',
|
|
|
|
- return_value='foo').start()
|
|
|
|
- mock.patch('git_cl.gerrit_util.GetProjectHead',
|
|
|
|
- return_value='refs/heads/master').start()
|
|
|
|
- # GetTargetRef returns new default branch since it has stale remote
|
|
|
|
- # information.
|
|
|
|
- mock.patch('git_cl.GetTargetRef',
|
|
|
|
- return_value='refs/heads/main').start()
|
|
|
|
- mock.patch('git_cl.RunGit').start()
|
|
|
|
-
|
|
|
|
- cl = git_cl.Changelist()
|
|
|
|
- options = optparse.Values()
|
|
|
|
- options.target_branch = 'refs/heads/master'
|
|
|
|
- cl.CMDUploadChange(options, [], 'foo', git_cl.ChangeDescription('bar'))
|
|
|
|
- # ensure upload is called twice
|
|
|
|
- self.assertEqual(len(m.mock_calls), 2)
|
|
|
|
- # option overrides on retry
|
|
|
|
- self.assertEqual(options.force, True)
|
|
|
|
- self.assertEqual(options.edit_description, False)
|
|
|
|
-
|
|
|
|
def test_get_cl_statuses_no_changes(self):
|
|
def test_get_cl_statuses_no_changes(self):
|
|
self.assertEqual([], list(git_cl.get_cl_statuses([], True)))
|
|
self.assertEqual([], list(git_cl.get_cl_statuses([], True)))
|
|
|
|
|
|
@@ -680,7 +633,7 @@ class TestGitCl(unittest.TestCase):
|
|
'git_new_branch.create_new_branch', self.mockGit.NewBranch).start()
|
|
'git_new_branch.create_new_branch', self.mockGit.NewBranch).start()
|
|
mock.patch(
|
|
mock.patch(
|
|
'scm.GIT.FetchUpstreamTuple',
|
|
'scm.GIT.FetchUpstreamTuple',
|
|
- return_value=('origin', 'refs/heads/master')).start()
|
|
|
|
|
|
+ return_value=('origin', 'refs/heads/main')).start()
|
|
mock.patch(
|
|
mock.patch(
|
|
'scm.GIT.CaptureStatus', return_value=[('M', 'foo.txt')]).start()
|
|
'scm.GIT.CaptureStatus', return_value=[('M', 'foo.txt')]).start()
|
|
# It's important to reset settings to not have inter-tests interference.
|
|
# It's important to reset settings to not have inter-tests interference.
|
|
@@ -776,7 +729,7 @@ class TestGitCl(unittest.TestCase):
|
|
def _gerrit_base_calls(cls, issue=None, fetched_description=None,
|
|
def _gerrit_base_calls(cls, issue=None, fetched_description=None,
|
|
fetched_status=None, other_cl_owner=None,
|
|
fetched_status=None, other_cl_owner=None,
|
|
custom_cl_base=None, short_hostname='chromium',
|
|
custom_cl_base=None, short_hostname='chromium',
|
|
- change_id=None, default_branch='master'):
|
|
|
|
|
|
+ change_id=None, default_branch='main'):
|
|
calls = []
|
|
calls = []
|
|
if custom_cl_base:
|
|
if custom_cl_base:
|
|
ancestor_revision = custom_cl_base
|
|
ancestor_revision = custom_cl_base
|
|
@@ -807,10 +760,6 @@ class TestGitCl(unittest.TestCase):
|
|
[ancestor_revision, 'HEAD']),),
|
|
[ancestor_revision, 'HEAD']),),
|
|
'+dat'),
|
|
'+dat'),
|
|
]
|
|
]
|
|
- calls += [
|
|
|
|
- ((['git', 'show-branch', 'refs/remotes/origin/main'], ),
|
|
|
|
- '1' if default_branch == 'main' else callError(1)),
|
|
|
|
- ]
|
|
|
|
|
|
|
|
return calls
|
|
return calls
|
|
|
|
|
|
@@ -833,7 +782,7 @@ class TestGitCl(unittest.TestCase):
|
|
gitcookies_exists=True,
|
|
gitcookies_exists=True,
|
|
force=False,
|
|
force=False,
|
|
edit_description=None,
|
|
edit_description=None,
|
|
- default_branch='master',
|
|
|
|
|
|
+ default_branch='main',
|
|
push_opts=None):
|
|
push_opts=None):
|
|
if post_amend_description is None:
|
|
if post_amend_description is None:
|
|
post_amend_description = description
|
|
post_amend_description = description
|
|
@@ -1140,7 +1089,7 @@ class TestGitCl(unittest.TestCase):
|
|
log_description=None,
|
|
log_description=None,
|
|
edit_description=None,
|
|
edit_description=None,
|
|
fetched_description=None,
|
|
fetched_description=None,
|
|
- default_branch='master',
|
|
|
|
|
|
+ default_branch='main',
|
|
push_opts=None):
|
|
push_opts=None):
|
|
"""Generic gerrit upload test framework."""
|
|
"""Generic gerrit upload test framework."""
|
|
if squash_mode is None:
|
|
if squash_mode is None:
|
|
@@ -1201,7 +1150,7 @@ class TestGitCl(unittest.TestCase):
|
|
lambda prompt: self._mocked_call('ask_for_data', prompt)).start()
|
|
lambda prompt: self._mocked_call('ask_for_data', prompt)).start()
|
|
|
|
|
|
self.mockGit.config['gerrit.host'] = 'true'
|
|
self.mockGit.config['gerrit.host'] = 'true'
|
|
- self.mockGit.config['branch.master.gerritissue'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = (
|
|
str(issue) if issue else None)
|
|
str(issue) if issue else None)
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
'https://%s.googlesource.com/my/repo' % short_hostname)
|
|
'https://%s.googlesource.com/my/repo' % short_hostname)
|
|
@@ -1248,7 +1197,7 @@ class TestGitCl(unittest.TestCase):
|
|
self.assertIssueAndPatchset(patchset=None)
|
|
self.assertIssueAndPatchset(patchset=None)
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
'abcdef0123456789',
|
|
'abcdef0123456789',
|
|
- scm.GIT.GetBranchConfig('', 'master', 'gerritsquashhash'))
|
|
|
|
|
|
+ scm.GIT.GetBranchConfig('', 'main', 'gerritsquashhash'))
|
|
|
|
|
|
def test_gerrit_upload_traces_no_gitcookies(self):
|
|
def test_gerrit_upload_traces_no_gitcookies(self):
|
|
self._run_gerrit_upload_test(
|
|
self._run_gerrit_upload_test(
|
|
@@ -1765,10 +1714,6 @@ class TestGitCl(unittest.TestCase):
|
|
self.assertEqual(expected, actual)
|
|
self.assertEqual(expected, actual)
|
|
|
|
|
|
def test_get_hash_tags(self):
|
|
def test_get_hash_tags(self):
|
|
- self.calls = [
|
|
|
|
- ((['git', 'show-branch', 'refs/remotes/origin/main'], ),
|
|
|
|
- callError(1)),
|
|
|
|
- ] * 9
|
|
|
|
cases = [
|
|
cases = [
|
|
('', []),
|
|
('', []),
|
|
('a', []),
|
|
('a', []),
|
|
@@ -1812,19 +1757,19 @@ class TestGitCl(unittest.TestCase):
|
|
expected,
|
|
expected,
|
|
'GetHashTags(%r) == %r, expected %r' % (desc, actual, expected))
|
|
'GetHashTags(%r) == %r, expected %r' % (desc, actual, expected))
|
|
|
|
|
|
- self.assertEqual(None, git_cl.GetTargetRef('origin', None, 'master'))
|
|
|
|
|
|
+ self.assertEqual(None, git_cl.GetTargetRef('origin', None, 'main'))
|
|
self.assertEqual(None, git_cl.GetTargetRef(None,
|
|
self.assertEqual(None, git_cl.GetTargetRef(None,
|
|
- 'refs/remotes/origin/master',
|
|
|
|
- 'master'))
|
|
|
|
|
|
+ 'refs/remotes/origin/main',
|
|
|
|
+ 'main'))
|
|
|
|
|
|
# Check default target refs for branches.
|
|
# Check default target refs for branches.
|
|
- self.assertEqual('refs/heads/master',
|
|
|
|
- git_cl.GetTargetRef('origin', 'refs/remotes/origin/master',
|
|
|
|
|
|
+ self.assertEqual('refs/heads/main',
|
|
|
|
+ git_cl.GetTargetRef('origin', 'refs/remotes/origin/main',
|
|
None))
|
|
None))
|
|
- self.assertEqual('refs/heads/master',
|
|
|
|
|
|
+ self.assertEqual('refs/heads/main',
|
|
git_cl.GetTargetRef('origin', 'refs/remotes/origin/lkgr',
|
|
git_cl.GetTargetRef('origin', 'refs/remotes/origin/lkgr',
|
|
None))
|
|
None))
|
|
- self.assertEqual('refs/heads/master',
|
|
|
|
|
|
+ self.assertEqual('refs/heads/main',
|
|
git_cl.GetTargetRef('origin', 'refs/remotes/origin/lkcr',
|
|
git_cl.GetTargetRef('origin', 'refs/remotes/origin/lkcr',
|
|
None))
|
|
None))
|
|
self.assertEqual('refs/branch-heads/123',
|
|
self.assertEqual('refs/branch-heads/123',
|
|
@@ -1845,16 +1790,16 @@ class TestGitCl(unittest.TestCase):
|
|
'refs/remotes/branch-heads/123'):
|
|
'refs/remotes/branch-heads/123'):
|
|
self.assertEqual('refs/branch-heads/123',
|
|
self.assertEqual('refs/branch-heads/123',
|
|
git_cl.GetTargetRef('origin',
|
|
git_cl.GetTargetRef('origin',
|
|
- 'refs/remotes/origin/master',
|
|
|
|
|
|
+ 'refs/remotes/origin/main',
|
|
branch))
|
|
branch))
|
|
- for branch in ('origin/master', 'remotes/origin/master',
|
|
|
|
- 'refs/remotes/origin/master'):
|
|
|
|
- self.assertEqual('refs/heads/master',
|
|
|
|
|
|
+ for branch in ('origin/main', 'remotes/origin/main',
|
|
|
|
+ 'refs/remotes/origin/main'):
|
|
|
|
+ self.assertEqual('refs/heads/main',
|
|
git_cl.GetTargetRef('origin',
|
|
git_cl.GetTargetRef('origin',
|
|
'refs/remotes/branch-heads/123',
|
|
'refs/remotes/branch-heads/123',
|
|
branch))
|
|
branch))
|
|
- for branch in ('master', 'heads/master', 'refs/heads/master'):
|
|
|
|
- self.assertEqual('refs/heads/master',
|
|
|
|
|
|
+ for branch in ('main', 'heads/main', 'refs/heads/main'):
|
|
|
|
+ self.assertEqual('refs/heads/main',
|
|
git_cl.GetTargetRef('origin',
|
|
git_cl.GetTargetRef('origin',
|
|
'refs/remotes/branch-heads/123',
|
|
'refs/remotes/branch-heads/123',
|
|
branch))
|
|
branch))
|
|
@@ -1865,7 +1810,7 @@ class TestGitCl(unittest.TestCase):
|
|
self.assertNotEqual(git_cl.main(['patch', '123456']), 0)
|
|
self.assertNotEqual(git_cl.main(['patch', '123456']), 0)
|
|
|
|
|
|
def assertIssueAndPatchset(
|
|
def assertIssueAndPatchset(
|
|
- self, branch='master', issue='123456', patchset='7',
|
|
|
|
|
|
+ self, branch='main', issue='123456', patchset='7',
|
|
git_short_host='chromium'):
|
|
git_short_host='chromium'):
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
issue, scm.GIT.GetBranchConfig('', branch, 'gerritissue'))
|
|
issue, scm.GIT.GetBranchConfig('', branch, 'gerritissue'))
|
|
@@ -2016,8 +1961,8 @@ class TestGitCl(unittest.TestCase):
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
'https://chromium.googlesource.com/my/repo')
|
|
'https://chromium.googlesource.com/my/repo')
|
|
cl = git_cl.Changelist()
|
|
cl = git_cl.Changelist()
|
|
- cl.branch = 'master'
|
|
|
|
- cl.branchref = 'refs/heads/master'
|
|
|
|
|
|
+ cl.branch = 'main'
|
|
|
|
+ cl.branchref = 'refs/heads/main'
|
|
return cl
|
|
return cl
|
|
|
|
|
|
@mock.patch('sys.stderr', StringIO())
|
|
@mock.patch('sys.stderr', StringIO())
|
|
@@ -2082,7 +2027,7 @@ class TestGitCl(unittest.TestCase):
|
|
(('logging.warning',
|
|
(('logging.warning',
|
|
'Ignoring branch %(branch)s with non-https remote '
|
|
'Ignoring branch %(branch)s with non-https remote '
|
|
'%(remote)s', {
|
|
'%(remote)s', {
|
|
- 'branch': 'master',
|
|
|
|
|
|
+ 'branch': 'main',
|
|
'remote': 'custom-scheme://repo'}
|
|
'remote': 'custom-scheme://repo'}
|
|
), None),
|
|
), None),
|
|
]
|
|
]
|
|
@@ -2091,8 +2036,8 @@ class TestGitCl(unittest.TestCase):
|
|
mock.patch('logging.warning',
|
|
mock.patch('logging.warning',
|
|
lambda *a: self._mocked_call('logging.warning', *a)).start()
|
|
lambda *a: self._mocked_call('logging.warning', *a)).start()
|
|
cl = git_cl.Changelist()
|
|
cl = git_cl.Changelist()
|
|
- cl.branch = 'master'
|
|
|
|
- cl.branchref = 'refs/heads/master'
|
|
|
|
|
|
+ cl.branch = 'main'
|
|
|
|
+ cl.branchref = 'refs/heads/main'
|
|
cl.lookedup_issue = True
|
|
cl.lookedup_issue = True
|
|
self.assertIsNone(cl.EnsureAuthenticated(force=False))
|
|
self.assertIsNone(cl.EnsureAuthenticated(force=False))
|
|
|
|
|
|
@@ -2104,7 +2049,7 @@ class TestGitCl(unittest.TestCase):
|
|
'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", '
|
|
'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", '
|
|
'but it doesn\'t exist.', {
|
|
'but it doesn\'t exist.', {
|
|
'remote': 'origin',
|
|
'remote': 'origin',
|
|
- 'branch': 'master',
|
|
|
|
|
|
+ 'branch': 'main',
|
|
'url': 'git@somehost.example:foo/bar.git'}
|
|
'url': 'git@somehost.example:foo/bar.git'}
|
|
), None),
|
|
), None),
|
|
]
|
|
]
|
|
@@ -2113,14 +2058,14 @@ class TestGitCl(unittest.TestCase):
|
|
mock.patch('logging.error',
|
|
mock.patch('logging.error',
|
|
lambda *a: self._mocked_call('logging.error', *a)).start()
|
|
lambda *a: self._mocked_call('logging.error', *a)).start()
|
|
cl = git_cl.Changelist()
|
|
cl = git_cl.Changelist()
|
|
- cl.branch = 'master'
|
|
|
|
- cl.branchref = 'refs/heads/master'
|
|
|
|
|
|
+ cl.branch = 'main'
|
|
|
|
+ cl.branchref = 'refs/heads/main'
|
|
cl.lookedup_issue = True
|
|
cl.lookedup_issue = True
|
|
self.assertIsNone(cl.EnsureAuthenticated(force=False))
|
|
self.assertIsNone(cl.EnsureAuthenticated(force=False))
|
|
|
|
|
|
def _cmd_set_commit_gerrit_common(self, vote, notify=None):
|
|
def _cmd_set_commit_gerrit_common(self, vote, notify=None):
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
- self.mockGit.config['branch.master.gerritserver'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
|
|
+ self.mockGit.config['branch.main.gerritserver'] = (
|
|
'https://chromium-review.googlesource.com')
|
|
'https://chromium-review.googlesource.com')
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
'https://chromium.googlesource.com/infra/infra')
|
|
'https://chromium.googlesource.com/infra/infra')
|
|
@@ -2131,8 +2076,8 @@ class TestGitCl(unittest.TestCase):
|
|
]
|
|
]
|
|
|
|
|
|
def _cmd_set_quick_run_gerrit(self):
|
|
def _cmd_set_quick_run_gerrit(self):
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
- self.mockGit.config['branch.master.gerritserver'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
|
|
+ self.mockGit.config['branch.main.gerritserver'] = (
|
|
'https://chromium-review.googlesource.com')
|
|
'https://chromium-review.googlesource.com')
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
'https://chromium.googlesource.com/infra/infra')
|
|
'https://chromium.googlesource.com/infra/infra')
|
|
@@ -2241,7 +2186,7 @@ class TestGitCl(unittest.TestCase):
|
|
UpdateDescription).start()
|
|
UpdateDescription).start()
|
|
mock.patch('git_cl.gclient_utils.RunEditor', RunEditor).start()
|
|
mock.patch('git_cl.gclient_utils.RunEditor', RunEditor).start()
|
|
|
|
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
self.assertEqual(0, git_cl.main(['description']))
|
|
self.assertEqual(0, git_cl.main(['description']))
|
|
|
|
|
|
def test_description_does_not_append_bug_line_if_fixed_is_present(self):
|
|
def test_description_does_not_append_bug_line_if_fixed_is_present(self):
|
|
@@ -2262,7 +2207,7 @@ class TestGitCl(unittest.TestCase):
|
|
lambda *args: current_desc).start()
|
|
lambda *args: current_desc).start()
|
|
mock.patch('git_cl.gclient_utils.RunEditor', RunEditor).start()
|
|
mock.patch('git_cl.gclient_utils.RunEditor', RunEditor).start()
|
|
|
|
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
self.assertEqual(0, git_cl.main(['description']))
|
|
self.assertEqual(0, git_cl.main(['description']))
|
|
|
|
|
|
def test_description_set_stdin(self):
|
|
def test_description_set_stdin(self):
|
|
@@ -2275,7 +2220,7 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive(self):
|
|
def test_archive(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
- 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
|
|
|
|
|
|
+ 'refs/heads/main\nrefs/heads/foo\nrefs/heads/bar'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'tag', 'git-cl-archived-456-foo', 'foo'],), ''),
|
|
((['git', 'tag', 'git-cl-archived-456-foo', 'foo'],), ''),
|
|
((['git', 'branch', '-D', 'foo'],), '')
|
|
((['git', 'branch', '-D', 'foo'],), '')
|
|
@@ -2283,7 +2228,7 @@ class TestGitCl(unittest.TestCase):
|
|
|
|
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
lambda branches, fine_grained, max_processes:
|
|
lambda branches, fine_grained, max_processes:
|
|
- [(MockChangelistWithBranchAndIssue('master', 1), 'open'),
|
|
|
|
|
|
+ [(MockChangelistWithBranchAndIssue('main', 1), 'open'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
|
|
|
|
@@ -2292,7 +2237,7 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive_tag_collision(self):
|
|
def test_archive_tag_collision(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
- 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
|
|
|
|
|
|
+ 'refs/heads/main\nrefs/heads/foo\nrefs/heads/bar'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],),
|
|
'refs/tags/git-cl-archived-456-foo'),
|
|
'refs/tags/git-cl-archived-456-foo'),
|
|
((['git', 'tag', 'git-cl-archived-456-foo-2', 'foo'],), ''),
|
|
((['git', 'tag', 'git-cl-archived-456-foo-2', 'foo'],), ''),
|
|
@@ -2301,7 +2246,7 @@ class TestGitCl(unittest.TestCase):
|
|
|
|
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
lambda branches, fine_grained, max_processes:
|
|
lambda branches, fine_grained, max_processes:
|
|
- [(MockChangelistWithBranchAndIssue('master', 1), 'open'),
|
|
|
|
|
|
+ [(MockChangelistWithBranchAndIssue('main', 1), 'open'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
|
|
|
|
@@ -2310,13 +2255,13 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive_current_branch_fails(self):
|
|
def test_archive_current_branch_fails(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
- 'refs/heads/master'),
|
|
|
|
|
|
+ 'refs/heads/main'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
]
|
|
]
|
|
|
|
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
lambda branches, fine_grained, max_processes:
|
|
lambda branches, fine_grained, max_processes:
|
|
- [(MockChangelistWithBranchAndIssue('master', 1),
|
|
|
|
|
|
+ [(MockChangelistWithBranchAndIssue('main', 1),
|
|
'closed')]).start()
|
|
'closed')]).start()
|
|
|
|
|
|
self.assertEqual(1, git_cl.main(['archive', '-f']))
|
|
self.assertEqual(1, git_cl.main(['archive', '-f']))
|
|
@@ -2324,13 +2269,13 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive_dry_run(self):
|
|
def test_archive_dry_run(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
- 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
|
|
|
|
|
|
+ 'refs/heads/main\nrefs/heads/foo\nrefs/heads/bar'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
]
|
|
]
|
|
|
|
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
lambda branches, fine_grained, max_processes:
|
|
lambda branches, fine_grained, max_processes:
|
|
- [(MockChangelistWithBranchAndIssue('master', 1), 'open'),
|
|
|
|
|
|
+ [(MockChangelistWithBranchAndIssue('main', 1), 'open'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
|
|
|
|
@@ -2339,14 +2284,14 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive_no_tags(self):
|
|
def test_archive_no_tags(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
- 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
|
|
|
|
|
|
+ 'refs/heads/main\nrefs/heads/foo\nrefs/heads/bar'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'branch', '-D', 'foo'],), '')
|
|
((['git', 'branch', '-D', 'foo'],), '')
|
|
]
|
|
]
|
|
|
|
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
lambda branches, fine_grained, max_processes:
|
|
lambda branches, fine_grained, max_processes:
|
|
- [(MockChangelistWithBranchAndIssue('master', 1), 'open'),
|
|
|
|
|
|
+ [(MockChangelistWithBranchAndIssue('main', 1), 'open'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
|
|
|
|
@@ -2355,7 +2300,7 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive_tag_cleanup_on_branch_deletion_error(self):
|
|
def test_archive_tag_cleanup_on_branch_deletion_error(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
|
|
- 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
|
|
|
|
|
|
+ 'refs/heads/main\nrefs/heads/foo\nrefs/heads/bar'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'],), ''),
|
|
((['git', 'tag', 'git-cl-archived-456-foo', 'foo'],),
|
|
((['git', 'tag', 'git-cl-archived-456-foo', 'foo'],),
|
|
'refs/tags/git-cl-archived-456-foo'),
|
|
'refs/tags/git-cl-archived-456-foo'),
|
|
@@ -2366,7 +2311,7 @@ class TestGitCl(unittest.TestCase):
|
|
|
|
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
mock.patch('git_cl.get_cl_statuses',
|
|
lambda branches, fine_grained, max_processes:
|
|
lambda branches, fine_grained, max_processes:
|
|
- [(MockChangelistWithBranchAndIssue('master', 1), 'open'),
|
|
|
|
|
|
+ [(MockChangelistWithBranchAndIssue('main', 1), 'open'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('foo', 456), 'closed'),
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
(MockChangelistWithBranchAndIssue('bar', 789), 'open')]).start()
|
|
|
|
|
|
@@ -2375,7 +2320,7 @@ class TestGitCl(unittest.TestCase):
|
|
def test_archive_with_format(self):
|
|
def test_archive_with_format(self):
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'], ),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'], ),
|
|
- 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
|
|
|
|
|
|
+ 'refs/heads/main\nrefs/heads/foo\nrefs/heads/bar'),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'], ), ''),
|
|
((['git', 'for-each-ref', '--format=%(refname)', 'refs/tags'], ), ''),
|
|
((['git', 'tag', 'archived/12-foo', 'foo'], ), ''),
|
|
((['git', 'tag', 'archived/12-foo', 'foo'], ), ''),
|
|
((['git', 'branch', '-D', 'foo'], ), ''),
|
|
((['git', 'branch', '-D', 'foo'], ), ''),
|
|
@@ -2389,19 +2334,19 @@ class TestGitCl(unittest.TestCase):
|
|
0, git_cl.main(['archive', '-f', '-p', 'archived/{issue}-{branch}']))
|
|
0, git_cl.main(['archive', '-f', '-p', 'archived/{issue}-{branch}']))
|
|
|
|
|
|
def test_cmd_issue_erase_existing(self):
|
|
def test_cmd_issue_erase_existing(self):
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
- self.mockGit.config['branch.master.gerritserver'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
|
|
+ self.mockGit.config['branch.main.gerritserver'] = (
|
|
'https://chromium-review.googlesource.com')
|
|
'https://chromium-review.googlesource.com')
|
|
self.calls = [
|
|
self.calls = [
|
|
((['git', 'log', '-1', '--format=%B'],), 'This is a description'),
|
|
((['git', 'log', '-1', '--format=%B'],), 'This is a description'),
|
|
]
|
|
]
|
|
self.assertEqual(0, git_cl.main(['issue', '0']))
|
|
self.assertEqual(0, git_cl.main(['issue', '0']))
|
|
- self.assertNotIn('branch.master.gerritissue', self.mockGit.config)
|
|
|
|
- self.assertNotIn('branch.master.gerritserver', self.mockGit.config)
|
|
|
|
|
|
+ self.assertNotIn('branch.main.gerritissue', self.mockGit.config)
|
|
|
|
+ self.assertNotIn('branch.main.gerritserver', self.mockGit.config)
|
|
|
|
|
|
def test_cmd_issue_erase_existing_with_change_id(self):
|
|
def test_cmd_issue_erase_existing_with_change_id(self):
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
- self.mockGit.config['branch.master.gerritserver'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
|
|
+ self.mockGit.config['branch.main.gerritserver'] = (
|
|
'https://chromium-review.googlesource.com')
|
|
'https://chromium-review.googlesource.com')
|
|
mock.patch('git_cl.Changelist.FetchDescription',
|
|
mock.patch('git_cl.Changelist.FetchDescription',
|
|
lambda _: 'This is a description\n\nChange-Id: Ideadbeef').start()
|
|
lambda _: 'This is a description\n\nChange-Id: Ideadbeef').start()
|
|
@@ -2411,12 +2356,12 @@ class TestGitCl(unittest.TestCase):
|
|
((['git', 'commit', '--amend', '-m', 'This is a description\n'],), ''),
|
|
((['git', 'commit', '--amend', '-m', 'This is a description\n'],), ''),
|
|
]
|
|
]
|
|
self.assertEqual(0, git_cl.main(['issue', '0']))
|
|
self.assertEqual(0, git_cl.main(['issue', '0']))
|
|
- self.assertNotIn('branch.master.gerritissue', self.mockGit.config)
|
|
|
|
- self.assertNotIn('branch.master.gerritserver', self.mockGit.config)
|
|
|
|
|
|
+ self.assertNotIn('branch.main.gerritissue', self.mockGit.config)
|
|
|
|
+ self.assertNotIn('branch.main.gerritserver', self.mockGit.config)
|
|
|
|
|
|
def test_cmd_issue_json(self):
|
|
def test_cmd_issue_json(self):
|
|
- self.mockGit.config['branch.master.gerritissue'] = '123'
|
|
|
|
- self.mockGit.config['branch.master.gerritserver'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritissue'] = '123'
|
|
|
|
+ self.mockGit.config['branch.main.gerritserver'] = (
|
|
'https://chromium-review.googlesource.com')
|
|
'https://chromium-review.googlesource.com')
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
self.mockGit.config['remote.origin.url'] = (
|
|
'https://chromium.googlesource.com/chromium/src'
|
|
'https://chromium.googlesource.com/chromium/src'
|
|
@@ -2483,8 +2428,8 @@ class TestGitCl(unittest.TestCase):
|
|
cl._GerritCommitMsgHookCheck(offer_removal=True)
|
|
cl._GerritCommitMsgHookCheck(offer_removal=True)
|
|
|
|
|
|
def test_GerritCmdLand(self):
|
|
def test_GerritCmdLand(self):
|
|
- self.mockGit.config['branch.master.gerritsquashhash'] = 'deadbeaf'
|
|
|
|
- self.mockGit.config['branch.master.gerritserver'] = (
|
|
|
|
|
|
+ self.mockGit.config['branch.main.gerritsquashhash'] = 'deadbeaf'
|
|
|
|
+ self.mockGit.config['branch.main.gerritserver'] = (
|
|
'chromium-review.googlesource.com')
|
|
'chromium-review.googlesource.com')
|
|
self.calls += [
|
|
self.calls += [
|
|
((['git', 'diff', 'deadbeaf'],), ''), # No diff.
|
|
((['git', 'diff', 'deadbeaf'],), ''), # No diff.
|
|
@@ -2958,7 +2903,7 @@ class TestGitCl(unittest.TestCase):
|
|
'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", '
|
|
'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", '
|
|
'but it doesn\'t exist.', {
|
|
'but it doesn\'t exist.', {
|
|
'remote': 'origin',
|
|
'remote': 'origin',
|
|
- 'branch': 'master',
|
|
|
|
|
|
+ 'branch': 'main',
|
|
'url': '/cache/this-dir-doesnt-exist'}
|
|
'url': '/cache/this-dir-doesnt-exist'}
|
|
), None),
|
|
), None),
|
|
]
|
|
]
|
|
@@ -2988,7 +2933,7 @@ class TestGitCl(unittest.TestCase):
|
|
'"%(remote)s" pointing to the git host.', {
|
|
'"%(remote)s" pointing to the git host.', {
|
|
'remote': 'origin',
|
|
'remote': 'origin',
|
|
'cache_path': '/cache/this-dir-exists',
|
|
'cache_path': '/cache/this-dir-exists',
|
|
- 'branch': 'master'}
|
|
|
|
|
|
+ 'branch': 'main'}
|
|
), None),
|
|
), None),
|
|
]
|
|
]
|
|
cl = git_cl.Changelist(issue=1)
|
|
cl = git_cl.Changelist(issue=1)
|
|
@@ -3009,7 +2954,7 @@ class TestGitCl(unittest.TestCase):
|
|
'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", '
|
|
'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", '
|
|
'but it doesn\'t exist.', {
|
|
'but it doesn\'t exist.', {
|
|
'remote': 'origin',
|
|
'remote': 'origin',
|
|
- 'branch': 'master',
|
|
|
|
|
|
+ 'branch': 'main',
|
|
'url': ''}
|
|
'url': ''}
|
|
), None),
|
|
), None),
|
|
]
|
|
]
|