Fix a cherrypick-robot PR that needs manual intervention
Fixes cherrypick-robot PRs by manually cherry-picking commits and applying necessary corrections.
/plugin marketplace add openshift-eng/ai-helpers/plugin install git@ai-helpers<pr-url> [error-messages]git:fix-cherrypick-robot-pr
/git:fix-cherrypick-robot-pr <pr-url> [error-messages]
The git:fix-cherrypick-robot-pr command replaces a cherrypick-robot PR with a clean, manually-crafted cherry-pick PR that includes fixes the robot cannot handle.
The cherrypick-robot creates automated PRs but cannot:
This command helps you create a replacement PR with all necessary fixes applied.
Use gh pr view <pr-url> to extract:
release-4.19)OCPBUGS-65944)Example:
gh pr view <pr-url> --json baseRefName,title,commits,number,statusCheckRollup
Parse the provided error output to identify:
Error sources (in priority order):
/path/to/ci-errors.log)# Discover the upstream remote (the main repository)
# Look for a remote that's not owned by the current user
UPSTREAM_REMOTE=$(git remote -v | grep "fetch" | grep -v "$(git config user.name)" | awk '{print $1}' | head -1)
# Discover the fork remote (your fork)
FORK_REMOTE=$(git remote -v | grep "$(git config user.name).*push" | awk '{print $1}' | head -1)
# If not found, fall back to common names
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-upstream}
FORK_REMOTE=${FORK_REMOTE:-origin}
# Fetch the latest base branch
git fetch $UPSTREAM_REMOTE <base-branch>
# Create new branch following naming convention
git checkout -b cherry-pick-<issue-number>-to-<base-branch> $UPSTREAM_REMOTE/<base-branch>
Example branch name: cherry-pick-12345-to-release-1.0
Cherry-pick all commits from the robot PR in order:
# For each commit hash extracted from the robot PR
git cherry-pick <commit-hash>
# OR use the cherry-pick-by-patch command
/git:cherry-pick-by-patch <commit-hash>
Handle any conflicts that arise during cherry-picking.
Based on the error analysis from step 2, apply the necessary fixes:
Analyze the errors to determine:
Common fix strategies:
make update, make generate)Apply fixes with clear commits:
# Make necessary changes based on error analysis
# Stage and commit each logical fix separately
git add <affected-files>
git commit -m "<clear description of what was fixed and why>"
Note: The specific fix commands will vary by repository. Consult the repository's documentation for:
# Use the discovered fork remote (from step 3)
# If running this step separately, rediscover the fork remote:
FORK_REMOTE=$(git remote -v | grep "$(git config user.name).*push" | awk '{print $1}' | head -1)
FORK_REMOTE=${FORK_REMOTE:-origin}
# Push to your fork
git push -u $FORK_REMOTE cherry-pick-<issue-number>-to-<base-branch>
# Create PR using gh CLI
gh pr create \
--base <base-branch> \
--title "[<base-branch>] <BUG-ID>: <Description>" \
--body "$(cat <<'EOF'
## Summary
Cherry-pick of <original-commits> to <base-branch> with manual fixes.
## Commits
- <commit-1-hash>: <commit-1-message>
- <commit-2-hash>: <commit-2-message>
## Fixes Applied
- <description-of-fix-1>
- <description-of-fix-2>
## References
- Original PR: #<robot-pr-number>
- JIRA: <bug-id>
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Add a comment to the robot PR explaining the closure:
gh pr comment <robot-pr-number> --body "Closing this PR in favor of #<new-pr-number> which includes the following fixes:
- <specific-fix-1>
- <specific-fix-2>
/close"
The /close command triggers the bot to close the PR.
/git:fix-cherrypick-robot-pr https://github.com/org/repo/pull/12345
Error messages:
[paste CI error output here]
The command will:
/git:fix-cherrypick-robot-pr https://github.com/org/repo/pull/12345
Error log file: /path/to/ci-errors.log
The command reads the error log file and processes it the same way as Example 1.
/git:fix-cherrypick-robot-pr https://github.com/org/repo/pull/12345
CI failure: https://ci-system.example.com/logs/...
The command fetches the CI logs from the provided URL and analyzes them.
/git:fix-cherrypick-robot-pr https://github.com/org/repo/pull/12345
If no error messages are provided, the command will:
gh pr viewhttps://github.com/org/repo/pull/12345)/path/to/ci-errors.log)Beyond what the robot can do:
cherry-pick-<issue>-to-<release>git remote -v and git config user.name to identify fork vs upstreamorigin for fork, upstream for main repo) if auto-discovery fails