Skip to content

Commit

Permalink
qisrc push: don't try to set reviewers when --no-review #97
Browse files Browse the repository at this point in the history
There was some logic missing here, this option is seldom used
and needed a test

Change-Id: If026508c2a33e38c42bfb4b86293e316053e7779
Reviewed-on: http://gerrit.aldebaran.lan/73252
Tested-by: gerrit
Reviewed-by: vbarbaresi <[email protected]>
  • Loading branch information
Vincent Barbaresi authored and vbarbaresi committed Jul 8, 2016
1 parent 8181d68 commit 8cb3945
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/qisrc/actions/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ def do(args):
if git_project.review:
maintainers = qisrc.maintainers.get(git_project, warn_if_none=True)
orphaned = any(x["name"] == "ORPHANED" for x in maintainers)
if orphaned:
if not args.review:
reviewers = list()
elif orphaned:
ui.warning("Project is orphaned, no reviewers set")
reviewers = list()
else:
reviewers = [x['email'] for x in maintainers]
reviewers.extend(args.reviewers or list())
# Prefer gerrit logins or groups instead of e-mails
reviewers = [x.split("@")[0] for x in reviewers]
# Prefer gerrit logins or groups instead of e-mails
reviewers = [x.split("@")[0] for x in reviewers]
qisrc.review.push(git_project, local_ref, remote_branch,
bypass_review=(not args.review),
dry_run=args.dry_run, reviewers=reviewers,
Expand Down
17 changes: 17 additions & 0 deletions python/qisrc/test/test_qisrc_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,20 @@ def test_orphaned_project(qisrc_action, git_server, record_messages):
record_messages.reset()
qisrc_action("push", "--project", "foo")
assert record_messages.find("Project is orphaned")

def test_no_reviewers_when_no_review(qisrc_action, git_server):
foo_repo = git_server.create_repo("foo.git", review=True)
qiproject_xml = """\
<project format="3">
<maintainer email="[email protected]">John Doe</maintainer>
</project>"""
git_server.push_file("foo.git", "qiproject.xml", qiproject_xml)
qisrc_action("init", git_server.manifest_url)
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
foo_git = TestGit(foo_proj.path)
foo_git.commit_file("a.txt", "a")
with mock.patch("qisrc.review.set_reviewers") as set_reviewers:
qisrc_action("push", "--no-review", "--project", "foo")
assert not set_reviewers.called

0 comments on commit 8cb3945

Please sign in to comment.