Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"name": "ci",
"source": "./plugins/ci",
"description": "A plugin to work with OpenShift CI and analyze Prow job results",
"version": "0.0.7"
"version": "0.0.8"
},
{
"name": "teams",
Expand Down
2 changes: 1 addition & 1 deletion docs/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"name": "Triage Regression"
}
],
"version": "0.0.7"
"version": "0.0.8"
},
{
"commands": [
Expand Down
2 changes: 1 addition & 1 deletion plugins/ci/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ci",
"description": "Tools for working with OpenShift CI and analyzing Prow job results",
"version": "0.0.7",
"version": "0.0.8",
"author": {
"name": "openshift"
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/ci/commands/revert-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ This command is useful when:
- This command follows the [Revertomatic](https://github.com/stbenjam/revertomatic) PR template format for consistency
- The original PR author is CC'd in the revert PR body
- To unrevert, the original author should revert the revert PR and layer a fix commit on top
- For repos using `UPSTREAM: <carry>:` commit conventions (e.g., openshift/kubernetes), the PR title adapts automatically
- For repos using `UPSTREAM: <tag>:` commit conventions (e.g., openshift/kubernetes and other repos carrying upstream patches), the commit message and PR title adapt automatically
- Merge conflicts are handled automatically when possible: trivial conflicts are resolved directly, non-trivial ones trigger reverting dependent commits

## See Also
Expand Down
41 changes: 35 additions & 6 deletions plugins/ci/skills/revert-pr/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ If the user also provided inline context as arguments, combine it with the JIRA-

### Step 6: Detect Commit Message Convention

Before creating the revert, check recent commits in the repository to determine if it uses a special commit/PR title prefix convention.
**YOU MUST ALWAYS DO THIS.** Before creating the revert, check recent commits in the repository to determine if it uses a special commit/PR title prefix convention. Skipping this step will cause `verify-commits` CI jobs to fail.

```bash
# Check the last 20 commit subjects on the base branch
Expand Down Expand Up @@ -176,6 +176,35 @@ git revert -m1 --no-edit "$merge_sha"

**Important**: The `-m1` flag tells git to revert relative to the first parent of the merge commit, which is the base branch. This effectively undoes the changes introduced by the PR.

#### Amend Commit Message for UPSTREAM Convention

If the UPSTREAM convention was detected in Step 6, you **MUST** amend the revert commit message to include the appropriate `UPSTREAM: <tag>:` prefix. The default `git revert` message (`Revert "..."`) will fail `verify-commits` CI checks.

Determine the appropriate tag by looking at the commit being reverted and the repo conventions (e.g., `<carry>`, `<drop>`).

```bash
# Set the tag based on the convention detected in Step 6
upstream_tag="carry" # or "drop", or a cherry-pick number — based on context

# Get the current commit message
current_msg=$(git log -1 --format=%B)

# Prepend the UPSTREAM: <tag>: prefix to the first line
amended_msg=$(echo "$current_msg" | sed "1s/^/UPSTREAM: <$upstream_tag>: /")

# Amend the commit
git commit --amend -m "$amended_msg"
```

This transforms the commit message from:
```text
Revert "Merge pull request #638 from author/branch"
```
to:
```text
UPSTREAM: <carry>: Revert "Merge pull request #638 from author/branch"
```

Comment thread
coderabbitai[bot] marked this conversation as resolved.
#### Handling Merge Conflicts

If `git revert` fails with conflicts, determine the best strategy:
Expand Down Expand Up @@ -264,19 +293,19 @@ Format remaining jobs as override commands:

### Step 9: Create the Revert PR with Revertomatic Template

**PR Title Format** depends on the commit convention detected in Step 5:
**PR Title Format** depends on the commit convention detected in Step 6:

**Standard repositories**:
```
```text
{JIRA}: Revert #{PR_NUMBER} "{ORIGINAL_TITLE}"
```
Example: `TRT-9999: Revert #1703 "Fix kubelet crash on restart"`

**UPSTREAM carry repositories** (e.g., openshift/kubernetes):
```text
{JIRA}: UPSTREAM: <tag>: Revert "{ORIGINAL_TITLE}"
```
{JIRA}: UPSTREAM: <carry>: Revert "{ORIGINAL_TITLE}" because {REASON}
```
Example: `TRT-9999: UPSTREAM: <carry>: Revert "UPSTREAM: 12345: Fix kubelet crash" because it broke e2e-aws nightly jobs`
Example: `TRT-9999: UPSTREAM: <carry>: Revert "UPSTREAM: 12345: Fix kubelet crash"`

**PR Body - Revertomatic Template**:

Expand Down