Skip to content

Github Automation: Add support for an optional colon after command name #66540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/utils/git/github-automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,12 @@ def execute_command(self) -> bool:
"""
This function reads lines from STDIN and executes the first command
that it finds. The 2 supported commands are:
/cherry-pick commit0 <commit1> <commit2> <...>
/branch <owner>/<repo>/<branch>
/cherry-pick<:> commit0 <commit1> <commit2> <...>
/branch<:> <owner>/<repo>/<branch>
"""
for line in sys.stdin:
line.rstrip()
m = re.search(r"/([a-z-]+)\s(.+)", line)
m = re.search(r"/([a-z-]+)(?::)?\s(.+)", line)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

Suggested change
m = re.search(r"/([a-z-]+)(?::)?\s(.+)", line)
m = re.search(r"/([a-z-]+):?\s(.+)", line)

Then the reader doesn't have to remember the rules for (?:...)s

if not m:
continue
command = m.group(1)
Expand Down