Skip to content

Commit

Permalink
Bug 1700179 - Add --no-wip to prevent reviewerless commits being tagg…
Browse files Browse the repository at this point in the history
…ed as WIP; r=zeid

Differential Revision: https://phabricator.services.mozilla.com/D109577
  • Loading branch information
globau committed Mar 25, 2021
1 parent 5f1ad97 commit 8d74b36
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
15 changes: 12 additions & 3 deletions mozphab/commands/submit.py
Expand Up @@ -254,7 +254,8 @@ def show_commit_stack(
if not commit["has-reviewers"]:
logger.warning(
"!! Missing reviewers\n"
' It will be submitted as "Changes Planned"'
' It will be submitted as "Changes Planned".\n'
" Run submit again with --no-wip to prevent this."
)

if show_rev_urls and commit["rev-id"]:
Expand Down Expand Up @@ -370,7 +371,7 @@ def update_commits_from_args(commits, args):
# Mark a commit as WIP if --wip is provided, or if the commit does not have
# any reviewers. This is in addition to checking for the WIP: prefix in
# helpers.augment_commits_from_body()
if args.wip or not commit["has-reviewers"]:
if not args.no_wip and (args.wip or not commit["has-reviewers"]):
commit["wip"] = True
else:
commit.setdefault("wip", False)
Expand Down Expand Up @@ -775,12 +776,20 @@ def add_parser(parser):
action="store_true",
help="Add a `check-in-needed tag to the top most revision",
)
submit_parser.add_argument(
wip_group = submit_parser.add_mutually_exclusive_group()
wip_group.add_argument(
"--wip",
"--plan-changes",
action="store_true",
help="Create or update a revision without requesting a code review",
)
wip_group.add_argument(
"--no-wip",
action="store_true",
help="Don't mark reviewer-less commits as work-in-progress. Commits "
"with descriptions that start with WIP: will continue to be "
"flagged as work-in-progress.",
)
submit_parser.add_argument(
"--less-context",
"--lesscontext",
Expand Down
17 changes: 16 additions & 1 deletion tests/test_submit.py
Expand Up @@ -666,11 +666,14 @@ def lwr(revs):
update = submit.update_commits_from_args

class Args:
def __init__(self, reviewer=None, blocker=None, bug=None, wip=False):
def __init__(
self, reviewer=None, blocker=None, bug=None, wip=False, no_wip=False
):
self.reviewer = reviewer
self.blocker = blocker
self.bug = bug
self.wip = wip
self.no_wip = no_wip

_commits = [
{"title": "A", "reviewers": dict(granted=[], request=[]), "bug-id": None},
Expand Down Expand Up @@ -765,12 +768,24 @@ def __init__(self, reviewer=None, blocker=None, bug=None, wip=False):
assert "one" in commits[1]["reviewers"]["request"]
assert "three!" in commits[1]["reviewers"]["request"]

# reviewerless should result in WIP commits
commits = copy.deepcopy(_commits)
update(commits, Args())
assert commits[0]["wip"]
assert not commits[1]["wip"]

# Force WIP
commits = copy.deepcopy(_commits)
update(commits, Args(wip=True))
assert commits[0]["wip"]
assert commits[1]["wip"]

# reviewerless with --no-wip shouldn't be WIP
commits = copy.deepcopy(_commits)
update(commits, Args(no_wip=True))
assert not commits[0]["wip"]
assert not commits[1]["wip"]

# Forcing blocking reviewers
commits = copy.deepcopy(_commits)
commits[1]["reviewers"]["granted"].append("two")
Expand Down

0 comments on commit 8d74b36

Please sign in to comment.