Skip to content

update_checkout (tests): Use 'main' for test branch #40129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions utils/update_checkout/tests/scheme_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,38 @@
'remote': {'id': 'repo2'},
},
},
'default-branch-scheme': 'master',
'default-branch-scheme': 'main',
'branch-schemes': {
'master': {
'aliases': ['master'],
'main': {
'aliases': ['main'],
'repos': {
'repo1': 'master',
'repo2': 'master',
'repo1': 'main',
'repo2': 'main',
}
}
}
}


class CallQuietlyException(Exception):
def __init__(self, command, returncode, output):
self.command = command
self.returncode = returncode
self.output = output

def __str__(self):
return f"Command returned a non-zero exit status {self.returncode}:\n"\
f"Command: {' '.join(self.command)}\n" \
f"Output: {self.output.decode('utf-8')}"


def call_quietly(*args, **kwargs):
with open(os.devnull, 'w') as f:
kwargs['stdout'] = f
kwargs['stderr'] = f
subprocess.check_call(*args, **kwargs)
kwargs['stderr'] = subprocess.STDOUT
try:
subprocess.check_output(*args, **kwargs)
except subprocess.CalledProcessError as e:
raise CallQuietlyException(command=e.cmd, returncode=e.returncode,
output=e.stdout) from e


def create_dir(d):
Expand Down Expand Up @@ -101,15 +115,19 @@ def setup_mock_remote(base_dir):
create_dir(remote_repo_path)
create_dir(local_repo_path)
call_quietly(['git', 'init', '--bare', remote_repo_path])
call_quietly(['git', 'symbolic-ref', 'HEAD', 'refs/heads/main'],
cwd=remote_repo_path)
call_quietly(['git', 'clone', '-l', remote_repo_path, local_repo_path])
call_quietly(['git', 'symbolic-ref', 'HEAD', 'refs/heads/main'],
cwd=local_repo_path)
for (i, (filename, contents)) in enumerate(v):
filename_path = os.path.join(local_repo_path, filename)
with open(filename_path, 'w') as f:
f.write(contents)
call_quietly(['git', 'add', filename], cwd=local_repo_path)
call_quietly(['git', 'commit', '-m', 'Commit %d' % i],
cwd=local_repo_path)
call_quietly(['git', 'push', 'origin', 'master'],
call_quietly(['git', 'push', 'origin', 'main'],
cwd=local_repo_path)

base_config = MOCK_CONFIG
Expand Down
2 changes: 1 addition & 1 deletion utils/update_checkout/tests/test_update_worktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_worktree(self):
self.call([self.update_checkout_path,
'--config', self.config_path,
'--source-root', self.worktree_path,
'--scheme', 'master'])
'--scheme', 'main'])

def setUp(self):
super(WorktreeTestCase, self).setUp()
Expand Down