diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 3905ad2a0..5d4842452 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -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", diff --git a/docs/data.json b/docs/data.json index 19e01cce4..d2e81a5bd 100644 --- a/docs/data.json +++ b/docs/data.json @@ -481,7 +481,7 @@ "name": "Triage Regression" } ], - "version": "0.0.7" + "version": "0.0.8" }, { "commands": [ diff --git a/plugins/ci/.claude-plugin/plugin.json b/plugins/ci/.claude-plugin/plugin.json index b34b78d0e..6fa9b2385 100644 --- a/plugins/ci/.claude-plugin/plugin.json +++ b/plugins/ci/.claude-plugin/plugin.json @@ -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" } diff --git a/plugins/ci/commands/revert-pr.md b/plugins/ci/commands/revert-pr.md index af3a2b9b7..ecfc8140e 100644 --- a/plugins/ci/commands/revert-pr.md +++ b/plugins/ci/commands/revert-pr.md @@ -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: :` commit conventions (e.g., openshift/kubernetes), the PR title adapts automatically +- For repos using `UPSTREAM: :` 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 diff --git a/plugins/ci/skills/revert-pr/SKILL.md b/plugins/ci/skills/revert-pr/SKILL.md index a708d4029..fb1099349 100644 --- a/plugins/ci/skills/revert-pr/SKILL.md +++ b/plugins/ci/skills/revert-pr/SKILL.md @@ -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 @@ -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: :` 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., ``, ``). + +```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: : 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: : Revert "Merge pull request #638 from author/branch" +``` + #### Handling Merge Conflicts If `git revert` fails with conflicts, determine the best strategy: @@ -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: : Revert "{ORIGINAL_TITLE}" ``` -{JIRA}: UPSTREAM: : Revert "{ORIGINAL_TITLE}" because {REASON} -``` -Example: `TRT-9999: UPSTREAM: : Revert "UPSTREAM: 12345: Fix kubelet crash" because it broke e2e-aws nightly jobs` +Example: `TRT-9999: UPSTREAM: : Revert "UPSTREAM: 12345: Fix kubelet crash"` **PR Body - Revertomatic Template**: