Skip to content

Commit

Permalink
upload: Support Update-Pr-Body as a commit tag
Browse files Browse the repository at this point in the history
This allows you to manually specify one or more prs
as no-update while maintaining the default option for
all other prs. (and vise versa)

Fixes: #140
nefdsfadseeee
fd
  • Loading branch information
jerry-skydio committed Mar 12, 2024
1 parent 9ea9f6a commit ced232d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion revup/topic_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def format_remote_branch(uploader: str, base_branch: str, topic: str) -> str:
TAG_RELATIVE = "relative"
TAG_RELATIVE_BRANCH = "relative-branch"
TAG_UPLOADER = "uploader"
TAG_UPDATE_PR_BODY = "update-pr-body"
VALID_TAGS = {
TAG_BRANCH,
TAG_LABEL,
Expand All @@ -57,6 +58,7 @@ def format_remote_branch(uploader: str, base_branch: str, topic: str) -> str:
TAG_ASSIGNEE,
TAG_TOPIC,
TAG_UPLOADER,
TAG_UPDATE_PR_BODY,
}

RE_COMMIT_LABEL = re.compile(r"^(?P<label1>[a-zA-Z\-_0-9]+):.*|^\[(?P<label2>[a-zA-Z\-_0-9]+)\].*")
Expand Down Expand Up @@ -468,6 +470,14 @@ async def populate_reviews(
if len(topic.tags[TAG_UPLOADER]) > 1:
raise RevupUsageException(f"Can't specify more than one uploader for topic {name}!")

if TAG_UPDATE_PR_BODY in topic.tags:
if len(topic.tags[TAG_UPDATE_PR_BODY]) > 1 or min(
topic.tags[TAG_UPDATE_PR_BODY]
).lower() not in {"true", "false"}:
raise RevupUsageException(
f"Invalid tags for update-pr-body: {topic.tags[TAG_UPDATE_PR_BODY]}"
)

relative_topic = ""
if force_relative_chain and seen_topics:
relative_topic = list(seen_topics)[-1]
Expand Down Expand Up @@ -1033,7 +1043,7 @@ async def query_github(self) -> None:

def populate_update_info(
self,
update_pr_body: bool,
update_pr_body_arg: bool,
) -> None:
"""
Populate information necessary to do PR creation / update in github.
Expand Down Expand Up @@ -1106,6 +1116,11 @@ def populate_update_info(
topic.tags[TAG_ASSIGNEE], self.names_to_logins
).difference(review.pr_info.assignees)

if TAG_UPDATE_PR_BODY in topic.tags:
update_pr_body = min(topic.tags[TAG_UPDATE_PR_BODY]).lower() == "true"
else:
update_pr_body = update_pr_body_arg

if review.pr_info.baseRef != review.remote_base:
review.pr_update.baseRef = review.remote_base
if update_pr_body and review.pr_info.body != body:
Expand Down

0 comments on commit ced232d

Please sign in to comment.