Skip to content

Conversation

@lbarcziova
Copy link
Member

@lbarcziova lbarcziova commented Nov 7, 2025

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +43 to +61
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
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant