diff --git a/CHANGELOG.md b/CHANGELOG.md index 53d8818b..1d765612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Release 0.1.15 (2021-04-11) +===== + +* Add `repo` flag to `emu fork switch` command: if a repository's name isn't openpilot and isn't a GitHub fork (no name redirection), you can use this option the first time you switch to the fork (remembers URL after that). + + Release 0.1.14 (2021-04-02) ===== diff --git a/commands/fork/__init__.py b/commands/fork/__init__.py index e0f2dc6f..39133ba9 100644 --- a/commands/fork/__init__.py +++ b/commands/fork/__init__.py @@ -14,6 +14,7 @@ REMOTE_BRANCHES_START = 'Remote branches:\n' REMOTE_BRANCH_START = 'Remote branch:' CLONING_PATH = '{}/.cloning'.format(OH_MY_COMMA_PATH) +DEFAULT_REPO_NAME = 'openpilot' def set_cloning(cloning): @@ -104,6 +105,7 @@ def __init__(self): self.commands = {'switch': Command(description='🍴 Switch between any openpilot fork', flags=[Flag('username', '👤 The username of the fork\'s owner to switch to, will use current fork if not provided', required=False, dtype='str'), Flag(['-b', '--branch'], '🌿 Branch to switch to, will use default branch if not provided', required=False, dtype='str'), + Flag(['-r', '--repo'], 'The repository name of the fork, if its name isn\'t openpilot', required=False, dtype='str'), Flag(['-f', '--force'], '💪 Similar to checkout -f, force checks out new branch overwriting any changes')]), 'list': Command(description='📜 See a list of installed forks and branches', flags=[Flag('fork', '🌿 See branches of specified fork', dtype='str')])} @@ -168,6 +170,7 @@ def _switch(self): username = flags.username branch = flags.branch + repo_name = flags.repo force_switch = flags.force if username is None: # branch is specified, so use current checked out fork/username _current_fork = self.fork_params.get('current_fork') @@ -190,10 +193,12 @@ def _switch(self): if remote_info is not None: remote_url = f'https://github.com/{username}/{remote_info.fork_name}' # dragonpilot doesn't have a GH redirect else: # for most forks, GH will redirect from /openpilot if user renames fork - remote_url = f'https://github.com/{username}/openpilot' + if repo_name is None: + repo_name = DEFAULT_REPO_NAME # openpilot + remote_url = f'https://github.com/{username}/{repo_name}' if not valid_fork_url(remote_url): - error('Invalid username! {} does not exist'.format(remote_url)) + error('Invalid username{}! {} does not exist'.format('' if flags.repo is None else ' or repository name', remote_url)) return r = check_output(['git', '-C', OPENPILOT_PATH, 'remote', 'add', username, remote_url])