-
Notifications
You must be signed in to change notification settings - Fork 59
Support Github auto-format for retriggering with other PR #2923
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,12 +134,22 @@ def parse_known_arguments(self, args: argparse.Namespace) -> None: | |
|
|
||
| def parse_unknown_arguments(self, unknown_args: list[str]) -> None: | ||
| # Process unknown_args to find pr_argument | ||
| # Supports these formats: | ||
| # - namespace/repo#<pr_id> | ||
| # - https://github.com/namespace/repo/pull/<pr_id> (GitHub auto-converts the above to this) | ||
| pr_argument_pattern = re.compile(r"^[^/\s]+/[^#\s]+#\d+$") | ||
| github_url_pattern = re.compile(r"^https://github\.com/([^/\s]+)/([^/\s]+)/pull/(\d+)$") | ||
| for arg in unknown_args: | ||
| if pr_argument_pattern.match(arg): | ||
| self.pr_argument = arg | ||
| logger.debug(f"Parsed pr_argument: {self.pr_argument}") | ||
| break | ||
| if match := github_url_pattern.match(arg): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We support this only for GitHub? Or GitHub is the only “UX-friendly” enough to do this crap? am afraid I know the answers to those two questions sigh
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Gitlab actually doesn't use the |
||
| # Convert GitHub URL format back to namespace/repo#pr_id format | ||
| namespace, repo, pr_id = match.groups() | ||
| self.pr_argument = f"{namespace}/{repo}#{pr_id}" | ||
| logger.debug(f"Parsed pr_argument from GitHub URL: {arg} -> {self.pr_argument}") | ||
| break | ||
|
|
||
|
|
||
| class TestingFarmJobHelper(CoprBuildJobHelper): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably wouldn't be a bad idea to have one regex for both, since you can capture what you need from both;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally it wouldn't be that bad of an idea to compile the regex(es) only once, e.g., in constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://regex101.com/r/sX7EJU/1
Note
^and$for boundaries, since it didn't work well with whole comments I copy-pastedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the two separate patterns keep the validation stricter (e.g. multi-level namespaces) and more explicit, so I would probably keep it that way