Allow specifying the branch name in `gh pr revert`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 64/100
Direzione di ricerca
Parti dal comando gh pr revert e segui il flusso di mutazione esistente di revertPullRequest. Verifica come l’endpoint proposto per rinominare il branch e la modifica del branch di base potrebbero inserirsi dopo la creazione, quindi aggiungi la copertura per --branch e --base; il lavoro è completato quando i revert funzionano con nomi personalizzati per branch e base, preservando il commit di revert generato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the feature or problem you'd like to solve
gh pr revert always creates the branch that GitHub names for you: revert-<PR number>-<head branch name>. There is no way to override it.
In a repository whose ruleset enables Restrict creations, that name falls outside the allowed patterns, so the ref cannot be created and the revert fails:
Repository rule violations found
Cannot create ref due to creations being restricted.
The same limit exists in the web UI and in the GraphQL revertPullRequest mutation (RevertPullRequestInput takes only pullRequestId, title, body, draft, clientMutationId), so today there is no supported way to revert a PR in such a repository. Users have to drop down to git revert -m 1 <merge commit> by hand, which also means getting the -m flag right depending on whether the PR was merged with a merge commit or squashed.
Proposed solution
Add flags to gh pr revert:
-b, --branch <name> Name of the branch to create for the revert
-B, --base <name> Base branch for the revert pull request
Both can be implemented on top of what already exists, without waiting for a server-side API change:
- call the
revertPullRequestmutation as today - if
--branchwas given, rename the created branch viaPOST /repos/{owner}/{repo}/branches/{branch}/rename - if
--basewas given, apply the equivalent ofgh pr edit --base
Doing the rename server-side keeps the revert commit that GitHub generated, so the result is identical to the current behaviour apart from the branch name.
If that sequence is considered too indirect, an alternative is to compute the revert locally (git revert in a temporary worktree, push, then gh pr create), though that requires a local clone and loses the "works from anywhere" property that gh pr revert has today.
Additional context
This is currently a hard blocker rather than an inconvenience: with Restrict creations enabled, gh pr revert cannot succeed at all, and the error message does not mention the branch name, so the cause is not obvious from the output.
I have also opened a discussion for the GitHub-side parts of this (the web UI field, the branchName GraphQL input, and the error message wording): https://github.com/orgs/community/discussions/206033
- Lingua principale
- Go
- Stelle
- 46.3k
- Fork
- 9.1k
- Merge medio
- 1g 7h
- PR unite (30g)
- 76
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cli/cli
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
more-info-needed needs-triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
-
bug gh-pr priority-2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
bug gh-pr priority-2
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug gh-auth priority-3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Issue simili
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
microsoft/agent-framework-go#1179 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
[Bug]: OLLAMA_KEEP_ALIVE="5m" / "24h" crashes Ollama embedding and vision models with ValueError Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
infiniflow/ragflow#20223 · 1 reazione ·
-
bug needs triage pkg/translator/faro
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
open-telemetry/opentelemetry-collector-contrib#51484 · 1 commento ·