Skip to content

Commit

Permalink
check the base if passed
Browse files Browse the repository at this point in the history
\n(feature/185_catch_gitcommand_error_on_non_existant_remote_target)
  • Loading branch information
aramnhammer committed Jun 7, 2020
1 parent c3be852 commit c36cb8a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ def test_review(mocker, git_repo):
assert result.exit_code == 0


def test_review_no_base(mocker, git_repo):
mocked_reviewer = mocker.Mock()
mocked_reviewer.review = mocker.Mock(return_value=[])
mocked_reviewer.create_review = mocker.Mock()
mocker.patch('zazu.config.Config.code_reviewer', return_value=mocked_reviewer)
with zazu.util.cd(git_repo.working_tree_dir):
runner = click.testing.CliRunner()
result = runner.invoke(zazu.cli.cli, ['dev', 'review', '--base', 'does-not-exist'])
assert result.exception
assert result.exit_code == 1


def test_review_existing(mocker, git_repo):
mocker.patch('webbrowser.open_new')
mocked_tracker = mocker.Mock()
Expand Down
5 changes: 5 additions & 0 deletions zazu/dev/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ def review(config, base, head):
"""Create or display pull request."""
code_reviewer = config.code_reviewer()
head = config.repo.active_branch.name if head is None else head
if base is not None:
try:
config.repo.git.show_branch('remotes/origin/{}'.format(base))
except git.exc.GitCommandError as e:
raise click.ClickException('failed to find remote branch: {}'.format(str(base)))
existing_reviews = code_reviewer.review(status='open', head=head, base=base)
if existing_reviews:
pr = zazu.util.pick(existing_reviews, 'Multiple reviews found, pick one')
Expand Down

0 comments on commit c36cb8a

Please sign in to comment.