Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

revert-pr

БесплатноБез исполняемых скриптовНе проверен

Git revert workflow and Revertomatic PR template for reverting merged PRs

openshift-engот openshift-eng★ 123 звезды на GitHub

Об этом скилле

Revert PR

This skill provides the detailed git revert workflow and the exact PR body template used by Revertomatic for reverting merged pull requests that break CI or nightly payloads.

When to Use This Skill

Use this skill when:

  • A merged PR needs to be reverted to restore CI signal
  • Following the OpenShift quick-revert policy
  • You need the exact Revertomatic template format for the revert PR body
  • You need to generate CI override commands for a revert PR

Optional Parameters

  • --draft: When set, create the revert PR as a draft (gh pr create --draft). Used by the experimental revert workflow to open experimental revert PRs that may be closed if the suspect is cleared.
  • --context: When the caller passes context directly (e.g., from an autonomous pipeline that already has all context in memory), skip the JIRA lookup in Step 5. The provided context string is used as-is for the {CONTEXT} template variable.

Prerequisites

  1. GitHub CLI (gh): Installed and authenticated

    • Check: gh auth status
  2. Git: Installed and configured

    • Check: which git
  3. Repository Access: User must have push access to their fork of the target repository

Implementation Steps

Step 1: Extract PR Information

Use the gh CLI to fetch all necessary details about the PR being reverted:

# Fetch PR details as JSON
pr_data=$(gh pr view "$PR_URL" --json number,title,author,mergeCommit,baseRefName,state)

# Extract fields
pr_number=$(echo "$pr_data" | jq -r '.number')
pr_title=$(echo "$pr_data" | jq -r '.title')
pr_author=$(echo "$pr_data" | jq -r '.author.login')
merge_sha=$(echo "$pr_data" | jq -r '.mergeCommit.oid')
base_branch=$(echo "$pr_data" | jq -r '.baseRefName')
pr_state=$(echo "$pr_data" | jq -r '.state')

Validation:

  • pr_state must be MERGED. If the PR is not merged, abort with an error.
  • merge_sha must not be empty or null.

Step 2: Identify the Upstream Repository

Parse the PR URL to determine owner and repository:

# From URL like https://github.com/openshift/kubernetes/pull/1703
# Extract: owner=openshift, repo=kubernetes

Step 3: Ensure User Has a Fork

# Get authenticated user
gh_user=$(gh api user --jq '.login')

# Check if fork exists; create one if not
if ! gh api "repos/$gh_user/$repo" &>/dev/null; then
    echo "Creating fork of $owner/$repo..."
    gh repo fork "$owner/$repo" --clone=false
    # Wait for fork to become available
    sleep 5
fi

Step 4: Clone and Set Up Repository

If no local repository is available:

# Clone upstream repo
git clone -b "$base_branch" "https://github.com/$owner/$repo.git" /tmp/revert-workdir
cd /tmp/revert-workdir

# Rename the default remote to 'upstream' so later steps can reference it consistently
git remote rename origin upstream

# Add the user's fork as the 'fork' remote (used for pushing the revert branch)
git remote add fork "[email protected]:$gh_user/$repo.git"

If using an existing local clone, ensure upstream points to the canonical repo and fork points to the user's fork:

# Verify remotes: 'upstream' must point to the canonical repo, 'fork' to the user's fork
git remote -v

# If 'upstream' is missing but 'origin' points to the canonical repo, rename it:
# git remote rename origin upstream

# If 'fork' is missing, add it:
# git remote add fork "[email protected]:$gh_user/$repo.git"

Step 5: Look Up JIRA Ticket for Context

If --context was provided: Skip the JIRA lookup entirely. Use the provided context string as-is for the {CONTEXT} template variable and proceed to Step 6. The caller has already gathered all necessary context.

Otherwise, when a JIRA ticket is provided, use the fetch-jira-issue skill to automatically gather context about what broke and which jobs need verification before unreverting.

# Path to the fetch-jira-issue script
jira_script="plugins/ci/skills/fetch-jira-issue/fetch_jira_issue.py"

# Fetch JIRA issue details
jira_data=$(python3 "$jira_script" "$JIRA" --format json 2>/dev/null)

Extract context from the JIRA issue:

From the JSON output, examine the summary, comments, and linked_prs fields to determine:

  1. What broke (for the {CONTEXT} template variable):

    • Look at the issue summary and description for mentions of failing jobs, payloads, or test names
    • Check comments for links to failing Prow jobs, payload pages, or Sippy reports
    • Look for patterns like e2e-aws, e2e-gcp, nightly, payload, or release stream URLs
  2. Verification jobs (for the unrevert instructions):

    • Identify which specific CI jobs are mentioned as broken in the ticket
    • These are the jobs the original author should run before re-landing their change
    • Common patterns: e2e-aws, e2e-gcp, `e2e-m
Полный SKILL.md на GitHub

Установить revert-pr в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл revert-pr?

Git revert workflow and Revertomatic PR template for reverting merged PRs

Как установить скилл revert-pr?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл revert-pr запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить revert-pr с