-
Notifications
You must be signed in to change notification settings - Fork 23
Support backporting specfile only patches and identify patches from Fedora #346
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
base: main
Are you sure you want to change the base?
Conversation
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.
Code Review
This pull request introduces a valuable optimization for backporting patches. It adds the capability to detect patches from dist-git sources (like Fedora) and apply specfile-only changes directly, bypassing the more complex cherry-pick or git-am workflows. This is achieved by adding a new DistgitDetectorTool and updating the agent's instructions. The changes are well-structured and the new logic is clearly documented in the agent's prompt. I've made one suggestion to improve code quality in the new tool.
| try: | ||
| parsed = urlparse(url.lower()) | ||
| hostname = parsed.hostname or "" | ||
| path = parsed.path.lower() | ||
|
|
||
| # Fedora dist-git | ||
| if "src.fedoraproject.org" in hostname: | ||
| return True | ||
|
|
||
| # RHEL/CentOS Stream GitLab | ||
| if "gitlab.com" in hostname: | ||
| return "/redhat/centos-stream/rpms/" in path or "/redhat/rhel/rpms/" in path | ||
|
|
||
| # Not a recognized dist-git source | ||
| return False | ||
|
|
||
| except Exception: | ||
| # If URL cannot be parsed, assume not dist-git | ||
| return False |
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.
The try...except Exception block is too broad and can hide unexpected bugs. According to Python best practices (like PEP 8 E722), you should avoid except Exception:. In this case, the try block is quite safe as url is validated as a string by Pydantic and urllib.parse.urlparse is robust against malformed URLs. The try...except block is likely unnecessary. Removing it makes the code cleaner and safer against masking unrelated errors.
parsed = urlparse(url.lower())
hostname = parsed.hostname or ""
path = parsed.path.lower()
# Fedora dist-git
if "src.fedoraproject.org" in hostname:
return True
# RHEL/CentOS Stream GitLab
if "gitlab.com" in hostname:
return "/redhat/centos-stream/rpms/" in path or "/redhat/rhel/rpms/" in path
# Not a recognized dist-git source
return False
TomasTomecek
left a comment
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.
LGTM, this looks pretty straightforward
Fixes packit/jotnar#164
Tested with https://gitlab.com/redhat/centos-stream/rpms/bzip2/commit/a297cb19307d0ec5a21f7e383e12a62597225c7f.patch