Skip to content

Commit 7f7758b

Browse files
committed
update_checkout: Use 'main' for test branch
In addition to following current best practices for inclusive terms, this also fixes an issue that occurs if a user has customized their local git config to use an alternate default branch name (using 'init.defaultBranch'). If a user has set 'init.defaultBranch' in their git config to anything other than master, the update_checkout tests fail. By setting the sybolic-ref for HEAD after initializing the bare repo, the user's setting will not affect the test.
1 parent 245745b commit 7f7758b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

utils/update_checkout/tests/scheme_mock.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
'remote': {'id': 'repo2'},
5151
},
5252
},
53-
'default-branch-scheme': 'master',
53+
'default-branch-scheme': 'main',
5454
'branch-schemes': {
55-
'master': {
56-
'aliases': ['master'],
55+
'main': {
56+
'aliases': ['main'],
5757
'repos': {
58-
'repo1': 'master',
59-
'repo2': 'master',
58+
'repo1': 'main',
59+
'repo2': 'main',
6060
}
6161
}
6262
}
@@ -101,15 +101,19 @@ def setup_mock_remote(base_dir):
101101
create_dir(remote_repo_path)
102102
create_dir(local_repo_path)
103103
call_quietly(['git', 'init', '--bare', remote_repo_path])
104+
call_quietly(['git', 'symbolic-ref', 'HEAD', 'refs/heads/main'],
105+
cwd=remote_repo_path)
104106
call_quietly(['git', 'clone', '-l', remote_repo_path, local_repo_path])
107+
call_quietly(['git', 'symbolic-ref', 'HEAD', 'refs/heads/main'],
108+
cwd=local_repo_path)
105109
for (i, (filename, contents)) in enumerate(v):
106110
filename_path = os.path.join(local_repo_path, filename)
107111
with open(filename_path, 'w') as f:
108112
f.write(contents)
109113
call_quietly(['git', 'add', filename], cwd=local_repo_path)
110114
call_quietly(['git', 'commit', '-m', 'Commit %d' % i],
111115
cwd=local_repo_path)
112-
call_quietly(['git', 'push', 'origin', 'master'],
116+
call_quietly(['git', 'push', 'origin', 'main'],
113117
cwd=local_repo_path)
114118

115119
base_config = MOCK_CONFIG

utils/update_checkout/tests/test_update_worktree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_worktree(self):
5353
self.call([self.update_checkout_path,
5454
'--config', self.config_path,
5555
'--source-root', self.worktree_path,
56-
'--scheme', 'master'])
56+
'--scheme', 'main'])
5757

5858
def setUp(self):
5959
super(WorktreeTestCase, self).setUp()

0 commit comments

Comments
 (0)