Skip to content

Commit

Permalink
Allow specifying topics to upload
Browse files Browse the repository at this point in the history
As a list of multiple arguments to upload.

If topics are specified, only those topics will be uploaded.
Those topics will also ignore no-self-authored-only.
Any topics that aren't found will warn.

Topic: onlytopics
Reviewers: brian-k
  • Loading branch information
jerry-skydio committed Apr 5, 2023
1 parent 1a86af9 commit cfe9067
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docs/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ revup upload - Modify or create code reviews.
`[--rebase] [--relative-chain] [--skip-confirm] [--dry-run]`
`[--status] [--no-cherry-pick] [--no-update-pr-body] [--review-graph]`
`[--trim-tags] [--create-local-branches] [--patchsets] [--auto-add-users=<o>]`
`[--labels=<labels>]`
`[--labels=<labels>] <topics>`

# DESCRIPTION

Expand Down Expand Up @@ -96,6 +96,11 @@ that conflicts will not happen.

# OPTIONS

**`<topics>`**
: Optionally specify any number of topic names to upload. If none are
specified, all topics are uploaded. If topics are specified they will
be uploaded regardless of author.

**--help, -h**
: Show this help page.

Expand Down
1 change: 1 addition & 0 deletions revup/revup.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ async def main() -> int:
p.add_argument("--base-branch", "-b")
p.add_argument("--relative-branch", "-e")

upload_parser.add_argument("topics", nargs="*")
upload_parser.add_argument("--rebase", "-r", action="store_true")
upload_parser.add_argument("--skip-confirm", "-s", action="store_true")
upload_parser.add_argument("--dry-run", "-d", action="store_true")
Expand Down
14 changes: 13 additions & 1 deletion revup/topic_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,21 @@ async def populate_reviews(
user_aliases: str = "",
auto_add_users: str = "",
self_authored_only: bool = False,
limit_topics: Optional[List[str]] = None,
) -> None:
"""
Populate reviews for already-parsed topics. Verify base branch and relative topic info to
ensure it is valid.
"""
seen_topics: Dict[str, Topic] = {}
for name, topic in list(self.topics.items()):
relative_topic = ""
if limit_topics:
if name not in limit_topics:
# If an explicit list was specified, don't upload other topics
continue
# Disable the self authored check if this topic was explicitly given
self_authored_only = False
limit_topics.remove(name)

if self_authored_only:
# Don't upload if this topic doesn't have commits authored by the current user
Expand All @@ -443,6 +450,7 @@ async def populate_reviews(
if len(topic.tags[TAG_UPLOADER]) > 1:
raise RevupUsageException(f"Can't specify more than one uploader for topic {name}!")

relative_topic = ""
if force_relative_chain and seen_topics:
relative_topic = list(seen_topics)[-1]
elif len(topic.tags[TAG_RELATIVE]) > 1:
Expand Down Expand Up @@ -609,6 +617,10 @@ async def populate_reviews(

seen_topics[name] = topic

if limit_topics:
for name in limit_topics:
logging.warning(f"Couldn't find any topic named {name}")

async def mark_rebases(self, skip_rebase: bool) -> None:
"""
Scan all topics and compare patch-ids to remote patch-ids. Appropriately mark any
Expand Down
1 change: 1 addition & 0 deletions revup/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def main(
user_aliases=args.user_aliases,
auto_add_users=args.auto_add_users,
self_authored_only=args.self_authored_only,
limit_topics=args.topics,
)

if not args.dry_run:
Expand Down

0 comments on commit cfe9067

Please sign in to comment.