Commit 7e133ff1 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Use main branch as the default branch

R=apolito@google.com

Change-Id: I6a2ed557b9e8d45194b2fe4ea5327ce62020733c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3000134Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 9eee47a8
......@@ -252,7 +252,7 @@ class GitWrapper(SCMWrapper):
def diff(self, options, _args, _file_list):
_, revision = gclient_utils.SplitUrlRevision(self.url)
if not revision:
revision = 'refs/remotes/%s/master' % self.remote
revision = 'refs/remotes/%s/main' % self.remote
self._Run(['-c', 'core.quotePath=false', 'diff', revision], options)
def pack(self, _options, _args, _file_list):
......@@ -866,7 +866,7 @@ class GitWrapper(SCMWrapper):
# Don't reuse the args.
return self.update(options, [], file_list)
default_rev = "refs/heads/master"
default_rev = "refs/heads/main"
if options.upstream:
if self._GetCurrentBranch():
upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path)
......
......@@ -104,8 +104,8 @@ TRACES_README_FORMAT = (
POSTUPSTREAM_HOOK = '.git/hooks/post-cl-land'
DESCRIPTION_BACKUP_FILE = '.git_cl_description_backup'
REFS_THAT_ALIAS_TO_OTHER_REFS = {
'refs/remotes/origin/lkgr': 'refs/remotes/origin/master',
'refs/remotes/origin/lkcr': 'refs/remotes/origin/master',
'refs/remotes/origin/lkgr': 'refs/remotes/origin/main',
'refs/remotes/origin/lkcr': 'refs/remotes/origin/main',
}
DEFAULT_OLD_BRANCH = 'refs/remotes/origin/master'
......
......@@ -707,7 +707,7 @@ def upstream_default():
pass
return ret
except subprocess2.CalledProcessError:
return 'origin/master'
return 'origin/main'
def root():
......
......@@ -216,7 +216,7 @@ class GIT(object):
except subprocess2.CalledProcessError:
pass
# Return default branch
return 'refs/remotes/%s/master' % remote
return 'refs/remotes/%s/main' % remote
@staticmethod
def GetBranch(cwd):
......
......@@ -28,7 +28,7 @@ import gclient_utils
import scm
import subprocess2
DEFAULT_BRANCH = 'master'
DEFAULT_BRANCH = 'main'
def write(path, content):
......
......@@ -18,7 +18,7 @@ import unittest
import gclient_utils
DEFAULT_BRANCH = 'master'
DEFAULT_BRANCH = 'main'
if sys.version_info.major == 3:
# pylint: disable=redefined-builtin
......@@ -138,7 +138,7 @@ class GitRepoSchema(object):
Every commit gets a tag 'tag_%(commit)s'
Every unique terminal commit gets a branch 'branch_%(commit)s'
Last commit in First line is the branch 'master'
Last commit in First line is the branch 'main'
Root commits get a ref 'root_%(commit)s'
Timestamps are in topo order, earlier commits (as indicated by their presence
......@@ -160,7 +160,7 @@ class GitRepoSchema(object):
commit_name). See the docstring on the GitRepo class for the format of
the data returned by this function.
"""
self.master = None
self.main = None
self.par_map = {}
self.data_cache = {}
self.content_fn = content_fn
......@@ -207,8 +207,8 @@ class GitRepoSchema(object):
for commit in commits:
self.add_partial(commit, parent)
parent = commit
if parent and not self.master:
self.master = parent
if parent and not self.main:
self.main = parent
for _ in self.walk(): # This will throw if there are any cycles.
pass
......@@ -308,8 +308,8 @@ class GitRepo(object):
for commit in schema.walk():
self._add_schema_commit(commit, schema.data_for(commit.name))
self.last_commit = self[commit.name]
if schema.master:
self.git('update-ref', 'refs/heads/master', self[schema.master])
if schema.main:
self.git('update-ref', 'refs/heads/main', self[schema.main])
def __getitem__(self, commit_name):
"""Gets the hash of a commit by its schema name.
......
......@@ -296,7 +296,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase):
'sync', '-v', '-v', '-v',
'--revision', 'src/repo2@%s' % self.githash('repo_2', 1),
'--patch-ref',
'%srepo_2@refs/heads/master:%s' % (
'%srepo_2@refs/heads/main:%s' % (
self.git_base, self.githash('repo_2', 2)),
])
# Assert that repo_2 files coincide with revision @2 (the patch ref)
......@@ -318,7 +318,7 @@ class GClientSmokeGIT(gclient_smoketest_base.GClientSmokeBase):
'sync', '-v', '-v', '-v',
'--revision', 'src/repo2@%s' % self.githash('repo_2', 1),
'--patch-ref',
'%srepo_2@refs/heads/master:%s' % (
'%srepo_2@refs/heads/main:%s' % (
self.git_base, self.githash('repo_2', 2)),
'--nohooks',
])
......
This diff is collapsed.
This diff is collapsed.
......@@ -197,8 +197,8 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
def testHashes(self):
ret = self.repo.run(
self.gc.hash_multi, *[
'master',
'master~3',
'main',
'main~3',
self.repo['E']+'~',
self.repo['D']+'^2',
'tag_C^{}',
......@@ -259,7 +259,7 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
def testBranches(self):
# This check fails with git 2.4 (see crbug.com/487172)
self.assertEqual(self.repo.run(set, self.gc.branches()),
{'master', 'branch_D', 'root_A'})
{'main', 'branch_D', 'root_A'})
def testDiff(self):
# Get the names of the blobs being compared (to avoid hard-coding).
......@@ -279,9 +279,9 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
self.repo.run(self.gc.diff, 'tag_C', 'tag_D').split('\n'))
def testDormant(self):
self.assertFalse(self.repo.run(self.gc.is_dormant, 'master'))
self.repo.git('config', 'branch.master.dormant', 'true')
self.assertTrue(self.repo.run(self.gc.is_dormant, 'master'))
self.assertFalse(self.repo.run(self.gc.is_dormant, 'main'))
self.repo.git('config', 'branch.main.dormant', 'true')
self.assertTrue(self.repo.run(self.gc.is_dormant, 'main'))
def testBlame(self):
def get_porcelain_for_commit(commit_name, lines):
......@@ -321,8 +321,8 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
def testParseCommitrefs(self):
ret = self.repo.run(
self.gc.parse_commitrefs, *[
'master',
'master~3',
'main',
'main~3',
self.repo['E']+'~',
self.repo['D']+'^2',
'tag_C^{}',
......@@ -337,9 +337,9 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
]
self.assertEqual(ret, [binascii.unhexlify(h) for h in hashes])
expected_re = r"one of \(u?'master', u?'bananas'\)"
expected_re = r"one of \(u?'main', u?'bananas'\)"
with self.assertRaisesRegexp(Exception, expected_re):
self.repo.run(self.gc.parse_commitrefs, 'master', 'bananas')
self.repo.run(self.gc.parse_commitrefs, 'main', 'bananas')
def testRepoRoot(self):
def cd_and_repo_root(path):
......@@ -356,7 +356,7 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
{'tag_'+l for l in 'ABCDE'})
def testTree(self):
tree = self.repo.run(self.gc.tree, 'master:some/files')
tree = self.repo.run(self.gc.tree, 'main:some/files')
file1 = self.COMMIT_A['some/files/file1']['data']
file2 = self.COMMIT_D['some/files/file2']['data']
file3 = self.COMMIT_A['some/files/file3']['data']
......@@ -370,16 +370,16 @@ class GitReadOnlyFunctionsTest(git_test_utils.GitRepoReadOnlyTestBase,
tree['file3'],
('100644', 'blob', git_test_utils.git_hash_data(file3)))
tree = self.repo.run(self.gc.tree, 'master:some')
tree = self.repo.run(self.gc.tree, 'main:some')
self.assertEqual(len(tree), 2)
# Don't check the tree hash because we're lazy :)
self.assertEqual(tree['files'][:2], ('040000', 'tree'))
tree = self.repo.run(self.gc.tree, 'master:wat')
tree = self.repo.run(self.gc.tree, 'main:wat')
self.assertEqual(tree, None)
def testTreeRecursive(self):
tree = self.repo.run(self.gc.tree, 'master:some', recurse=True)
tree = self.repo.run(self.gc.tree, 'main:some', recurse=True)
file1 = self.COMMIT_A['some/files/file1']['data']
file2 = self.COMMIT_D['some/files/file2']['data']
file3 = self.COMMIT_A['some/files/file3']['data']
......@@ -448,7 +448,7 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
self.assertEqual(
'cat', self.repo.run(self.gc.get_config, 'dude.bob', 'cat'))
self.assertEqual('origin/master', self.repo.run(self.gc.root))
self.assertEqual('origin/main', self.repo.run(self.gc.root))
self.repo.git('config', 'depot-tools.upstream', 'catfood')
......@@ -460,7 +460,7 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
B D
""", self.getRepoContent)
origin = origin_schema.reify()
# Set the default branch to branch_D instead of master.
# Set the default branch to branch_D instead of main.
origin.git('checkout', 'branch_D')
self.repo.git('remote', 'add', 'origin', origin.repo_path)
......@@ -471,10 +471,10 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
def testUpstream(self):
self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
self.assertEqual(self.repo.run(self.gc.upstream, 'bobly'), None)
self.assertEqual(self.repo.run(self.gc.upstream, 'master'), None)
self.repo.git('checkout', '-tb', 'happybranch', 'master')
self.assertEqual(self.repo.run(self.gc.upstream, 'main'), None)
self.repo.git('checkout', '-tb', 'happybranch', 'main')
self.assertEqual(self.repo.run(self.gc.upstream, 'happybranch'),
'master')
'main')
def testNormalizedVersion(self):
self.assertTrue(all(
......@@ -482,11 +482,11 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
def testGetBranchesInfo(self):
self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
self.repo.git('checkout', '-tb', 'happybranch', 'master')
self.repo.git('checkout', '-tb', 'happybranch', 'main')
self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
self.repo.git('checkout', '-tb', 'child', 'happybranch')
self.repo.git('checkout', '-tb', 'to_delete', 'master')
self.repo.git('checkout', '-tb', 'to_delete', 'main')
self.repo.git('checkout', '-tb', 'parent_gone', 'to_delete')
self.repo.git('branch', '-D', 'to_delete')
......@@ -498,7 +498,7 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
expected = {
'happybranch': (
self.repo.run(self.gc.hash_one, 'happybranch', short=True),
'master',
'main',
1 if supports_track else None,
None
),
......@@ -508,8 +508,8 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
None,
None
),
'master': (
self.repo.run(self.gc.hash_one, 'master', short=True),
'main': (
self.repo.run(self.gc.hash_one, 'main', short=True),
'',
None,
None
......@@ -527,10 +527,10 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
def testGetBranchesInfoWithReset(self):
self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
self.repo.git('checkout','-tb', 'foobarA', 'master')
self.repo.git('checkout','-tb', 'foobarA', 'main')
self.repo.git('config', 'branch.foobarA.base',
self.repo.run(self.gc.hash_one, 'master'))
self.repo.git('config', 'branch.foobarA.base-upstream', 'master')
self.repo.run(self.gc.hash_one, 'main'))
self.repo.git('config', 'branch.foobarA.base-upstream', 'main')
with self.repo.open('foobar1', 'w') as f:
f.write('hello')
......@@ -558,7 +558,7 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
expected = {
'foobarA': (
self.repo.run(self.gc.hash_one, 'foobarA', short=True),
'master',
'main',
2,
None
),
......@@ -568,8 +568,8 @@ class GitMutableFunctionsTest(git_test_utils.GitRepoReadWriteTestBase,
None,
1
),
'master': (
self.repo.run(self.gc.hash_one, 'master', short=True),
'main': (
self.repo.run(self.gc.hash_one, 'main', short=True),
'',
None,
None
......@@ -695,7 +695,7 @@ class GitMutableStructuredTest(git_test_utils.GitRepoReadWriteTestBase,
def testMergeBaseWithForkPoint(self):
self.repo.git('commit', '--allow-empty', '-am', 'foooooo')
self.repo.git('checkout','-tb', 'foobarA', 'master')
self.repo.git('checkout','-tb', 'foobarA', 'main')
foobarA = self.repo.run(self.gc.hash_one, 'foobarA', short=True)
self.repo.git('checkout','-tb', 'foobarB', 'foobarA')
......@@ -726,7 +726,7 @@ class GitMutableStructuredTest(git_test_utils.GitRepoReadWriteTestBase,
def testGetBranchTree(self):
skipped, tree = self.repo.run(self.gc.get_branch_tree)
# This check fails with git 2.4 (see crbug.com/487172)
self.assertEqual(skipped, {'master', 'root_X', 'branch_DOG', 'root_CAT'})
self.assertEqual(skipped, {'main', 'root_X', 'branch_DOG', 'root_CAT'})
self.assertEqual(tree, {
'branch_G': 'root_A',
'root_A': 'root_X',
......
......@@ -24,11 +24,11 @@ class GitFootersTest(unittest.TestCase):
_message = """
This is my commit message. There are many like it, but this one is mine.
My commit message is my best friend. It is my life. I must master it.
My commit message is my best friend. It is my life.
"""
_position = 'refs/heads/master@{#292272}'
_position = 'refs/heads/main@{#292272}'
_position_footer = 'Cr-Commit-Position: %s\n' % _position
......
......@@ -50,13 +50,13 @@ class GitMapTest(git_test_utils.GitRepoReadOnlyTestBase):
J L
""", self.getRepoContent)
self.origin = origin_schema.reify()
self.origin.git('checkout', 'master')
self.origin.git('checkout', 'main')
self.origin.git('branch', '-d', *['branch_'+l for l in 'KLG'])
self.repo.git('remote', 'add', 'origin', self.origin.repo_path)
self.repo.git('config', '--add', 'remote.origin.fetch',
'+refs/tags/*:refs/tags/*')
self.repo.git('update-ref', 'refs/remotes/origin/master', 'tag_E')
self.repo.git('update-ref', 'refs/remotes/origin/main', 'tag_E')
self.repo.git('branch', '--set-upstream-to', 'branch_G', 'branch_K')
self.repo.git('branch', '--set-upstream-to', 'branch_K', 'branch_L')
......@@ -79,7 +79,7 @@ class GitMapTest(git_test_utils.GitRepoReadOnlyTestBase):
def testGitMap(self):
expected = os.linesep.join([
'* 6e85e877ea (tag_O, origin/master, origin/branch_O) 1970-01-30 ~ O',
'* 6e85e877ea (tag_O, origin/main, origin/branch_O) 1970-01-30 ~ O',
'* 4705470871 (tag_N) 1970-01-28 ~ N',
'* 8761b1a94f (tag_M) 1970-01-26 ~ M',
'* 5e7ce08691 (tag_G) 1970-01-24 ~ G',
......@@ -110,7 +110,7 @@ class GitMapTest(git_test_utils.GitRepoReadOnlyTestBase):
'|/ ',
'* 315457dbe8 (tag_B) 1970-01-04 ~ B',
'* cd589e62d8 (tag_A, origin/root_A) 1970-01-02 ~ A',
'* 7026d3d68e (tag_", root_", master, branch_") 1970-01-02 ~ "',
'* 7026d3d68e (tag_", root_", main, branch_") 1970-01-02 ~ "',
])
outbuf = io.BytesIO()
self.repo.run(git_map.main, [], outbuf)
......
......@@ -54,18 +54,18 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
J L
""", self.getRepoContent)
self.origin = origin_schema.reify()
self.origin.git('checkout', 'master')
self.origin.git('checkout', 'main')
self.origin.git('branch', '-d', *['branch_'+l for l in 'KLG'])
self.repo.git('remote', 'add', 'origin', self.origin.repo_path)
self.repo.git('config', '--add', 'remote.origin.fetch',
'+refs/tags/*:refs/tags/*')
self.repo.git('update-ref', 'refs/remotes/origin/master', 'tag_E')
self.repo.git('update-ref', 'refs/remotes/origin/main', 'tag_E')
self.repo.git('branch', '--set-upstream-to', 'branch_G', 'branch_K')
self.repo.git('branch', '--set-upstream-to', 'branch_K', 'branch_L')
self.repo.git('branch', '--set-upstream-to', 'origin/master', 'branch_G')
self.repo.git('branch', '--set-upstream-to', 'origin/main', 'branch_G')
self.repo.to_schema_refs += ['origin/master']
self.repo.to_schema_refs += ['origin/main']
def tearDown(self):
self.origin.nuke()
......@@ -76,7 +76,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.repo.run(self.nb.main, ['foobar'])
self.assertEqual(self.repo.git('rev-parse', 'HEAD').stdout,
self.repo.git('rev-parse', 'origin/master').stdout)
self.repo.git('rev-parse', 'origin/main').stdout)
with self.repo.open('foobar', 'w') as f:
f.write('this is the foobar file')
......@@ -109,7 +109,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.repo.git_commit('old_file')
self.repo.git('config', 'branch.old_branch.dormant', 'true')
self.repo.git('checkout', 'origin/master')
self.repo.git('checkout', 'origin/main')
self.assertSchema("""
A B H I J K sub_K
......@@ -144,7 +144,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.assertIn('Deleted branch empty_branch2', output)
self.assertIn('Deleted branch int1_foobar', output)
self.assertIn('Deleted branch int2_foobar', output)
self.assertIn('Reparented branch_K to track origin/master', output)
self.assertIn('Reparented branch_K to track origin/main', output)
self.assertIn('Reparented sub_foobar to track foobar', output)
self.assertSchema("""
......@@ -165,14 +165,14 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.assertEqual(self.repo.git('status', '--porcelain').stdout, '?? bob\n')
self.repo.git('checkout', 'origin/master')
self.repo.git('checkout', 'origin/main')
_, err = self.repo.capture_stdio(self.rp.main, [])
self.assertIn('Must specify new parent somehow', err)
_, err = self.repo.capture_stdio(self.rp.main, ['foobar'])
self.assertIn('Must be on the branch', err)
self.repo.git('checkout', 'branch_K')
_, err = self.repo.capture_stdio(self.rp.main, ['origin/master'])
_, err = self.repo.capture_stdio(self.rp.main, ['origin/main'])
self.assertIn('Cannot reparent a branch to its existing parent', err)
output, _ = self.repo.capture_stdio(self.rp.main, ['foobar'])
self.assertIn('Rebasing: branch_K', output)
......@@ -205,7 +205,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.assertEqual(self.repo.git('status', '--porcelain').stdout, '?? bob\n')
branches = self.repo.run(set, self.gc.branches())
self.assertEqual(branches, {'branch_K', 'master', 'sub_K', 'root_A',
self.assertEqual(branches, {'branch_K', 'main', 'sub_K', 'root_A',
'branch_L', 'old_branch', 'foobar',
'sub_foobar'})
......@@ -213,18 +213,18 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.repo.run(self.mv.main, ['special_K'])
branches = self.repo.run(set, self.gc.branches())
self.assertEqual(branches, {'special_K', 'master', 'sub_K', 'root_A',
self.assertEqual(branches, {'special_K', 'main', 'sub_K', 'root_A',
'branch_L', 'old_branch', 'foobar',
'sub_foobar'})
self.repo.git('checkout', 'origin/master')
self.repo.git('checkout', 'origin/main')
_, err = self.repo.capture_stdio(self.mv.main, ['special_K', 'cool branch'])
self.assertIn('fatal: \'cool branch\' is not a valid branch name.', err)
self.repo.run(self.mv.main, ['special_K', 'cool_branch'])
branches = self.repo.run(set, self.gc.branches())
# This check fails with git 2.4 (see crbug.com/487172)
self.assertEqual(branches, {'cool_branch', 'master', 'sub_K', 'root_A',
self.assertEqual(branches, {'cool_branch', 'main', 'sub_K', 'root_A',
'branch_L', 'old_branch', 'foobar',
'sub_foobar'})
......@@ -234,7 +234,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
def testRebaseConflicts(self):
# Pretend that branch_L landed
self.origin.git('checkout', 'master')
self.origin.git('checkout', 'main')
with self.origin.open('L', 'w') as f:
f.write('L')
self.origin.git('add', 'L')
......@@ -276,11 +276,11 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
self.assertIn('Deleted branch branch_G', output)
self.assertIn('Deleted branch branch_L', output)
self.assertIn('\'branch_G\' was merged', output)
self.assertIn('checking out \'origin/master\'', output)
self.assertIn('checking out \'origin/main\'', output)
def testRebaseConflictsKeepGoing(self):
# Pretend that branch_L landed
self.origin.git('checkout', 'master')
self.origin.git('checkout', 'main')
with self.origin.open('L', 'w') as f:
f.write('L')
self.origin.git('add', 'L')
......@@ -383,7 +383,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
""")
output, _ = self.repo.capture_stdio(self.rp.main, ['--root'])
self.assertIn('to track origin/master (was lkgr [tag])', output)
self.assertIn('to track origin/main (was lkgr [tag])', output)
self.assertSchema("""
A B C D E F G M N O foobar1 foobar2
......
......@@ -665,7 +665,7 @@ class MetricsUtilsTest(unittest.TestCase):
"""Tests that we extract paths for /changes/."""
# /changes/<change-id>
http_metrics = metrics_utils.extract_http_metrics(
'https://review.example.com/changes/proj%2Fsrc%7Emaster%7EI1234abcd',
'https://review.example.com/changes/proj%2Fsrc%7Emain%7EI1234abcd',
'', 0, 0)
self.assertEqual('changes', http_metrics['path'])
......
......@@ -250,18 +250,18 @@ class RealGitTest(fake_repos.FakeReposTestBase):
scm.GIT.SetBranchConfig(self.cwd, branch, 'remote')
def testGetBranchRef(self):
self.assertEqual('refs/heads/master', scm.GIT.GetBranchRef(self.cwd))
self.assertEqual('refs/heads/main', scm.GIT.GetBranchRef(self.cwd))
HEAD = scm.GIT.Capture(['rev-parse', 'HEAD'], cwd=self.cwd)
scm.GIT.Capture(['checkout', HEAD], cwd=self.cwd)
self.assertIsNone(scm.GIT.GetBranchRef(self.cwd))
scm.GIT.Capture(['checkout', 'master'], cwd=self.cwd)
scm.GIT.Capture(['checkout', 'main'], cwd=self.cwd)
def testGetBranch(self):
self.assertEqual('master', scm.GIT.GetBranch(self.cwd))
self.assertEqual('main', scm.GIT.GetBranch(self.cwd))
HEAD = scm.GIT.Capture(['rev-parse', 'HEAD'], cwd=self.cwd)
scm.GIT.Capture(['checkout', HEAD], cwd=self.cwd)
self.assertIsNone(scm.GIT.GetBranchRef(self.cwd))
scm.GIT.Capture(['checkout', 'master'], cwd=self.cwd)
scm.GIT.Capture(['checkout', 'main'], cwd=self.cwd)
if __name__ == '__main__':
......
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