Skip to content

Conversation

@lbarcziova
Copy link
Member

@lbarcziova lbarcziova commented Nov 11, 2025

Without this, the git am workfow doesn't work, as the patch file always starts with -0 suffix.
Example: https://gitlab.com/redhat/centos-stream/rpms/apr-util/-/merge_requests/17/diffs

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 aims to fix an issue in the git am workflow where patch files with suffixes (e.g., -0) were not being staged. The change correctly uses a glob pattern to find all patch files prefixed with the Jira issue key. This is a good fix that addresses the problem.

I've added one high-severity comment regarding the fallback logic. The current implementation can lead to silent failures if the fallback patch file doesn't exist. My suggestion is to add an explicit check for the file's existence and raise an exception if it's not found, ensuring the workflow halts correctly instead of proceeding with an incomplete set of changes.

Without this, the git am workfow doesn't work, as the patch file always starts with -0 suffix.
@lbarcziova lbarcziova force-pushed the backport-staging-all-patches branch from cc0c611 to 3b36789 Compare November 11, 2025 19:43
@lbarcziova
Copy link
Member Author

/gemini review

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 updates the backport agent to correctly stage all patch files associated with a Jira issue. The previous implementation used a hardcoded patch file name, which would fail for workflows that generate multiple patch files with suffixes (e.g., -0, -1). The new implementation uses pathlib.Path.glob to find all files matching the pattern {jira_issue}*.patch, ensuring that all relevant patches are staged for commit. The change is correct, well-implemented, and improves the robustness of the backporting process.

async def stage_changes(state):
try:
# Find all patch files matching the jira issue pattern
patch_files = list(state.local_clone.glob(f"{state.jira_issue}*.patch"))
Copy link
Member

Choose a reason for hiding this comment

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

I would maybe use a bit stricter pattern, to match what's in the instructions:

Suggested change
patch_files = list(state.local_clone.glob(f"{state.jira_issue}*.patch"))
patch_files = list(state.local_clone.glob(f"{state.jira_issue}-*.patch"))

Copy link
Member Author

Choose a reason for hiding this comment

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

but for cherry-pick workflow, it doesn't seem to add the suffix (example). We might unify it later, but for fixing the git am workflow, I am going to merge this.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, right, sorry, my bad.

@lbarcziova lbarcziova merged commit e1dd00d into packit:main Nov 12, 2025
7 checks passed
@lbarcziova lbarcziova deleted the backport-staging-all-patches branch November 12, 2025 10:12
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.

2 participants