fx revertfx revert is a host tool that orchestrates pure reverts of submitted Gerrit changes across Fuchsia repositories (e.g. fuchsia.git and vendor/google).
It generates authentic Gerrit server-side reverts via Gerrit's REST API, ensuring that Rubber Stamper (rubber-stamper@appspot.gserviceaccount.com) automatically recognizes the reverts and approves them with Bot-Commit +1 / Code-Review +2.
/revert REST endpoint. The change must be MERGED; its Depends-on footers are reported but related changes are not reverted automatically.fx-worktree checkouts), rejecting projects from mismatched hosts and paths outside the checkout.origin and fetches any missing objects by SHA without a refmap, so no refs, reflogs, FETCH_HEAD, or other user-visible repository state is modified. Falls back to the local copy of the change’s branch when the remote is unreachable.git merge-tree (no working-tree, index, or ref modifications) on top of the up-to-date branch tip to verify conflict-free execution before making any API calls. Reverts that conflict with later changes are rejected.Depends-on footers, and partitions it into topological waves of submission clusters that are printed with the plan.Fuchsia-Auto-Submit +1 for hands-off tree unblocking.Reason for revert:, Failure Link:, and Bug: references.fx revert is a Bazel-only fx host tool: it is registered in //tools/devshell/fx_host_tools.json and built on demand the first time it is run (and whenever its sources change), so no fx set or fx build step is required.
To build the tool explicitly:
fx bazel build --config=host //tools/revert:fx_revert
fx revert reads local Git repositories to plan and simulate reverts, while the reverts themselves are created through Gerrit's REST API. It never modifies any user-visible repository state:
fx revert must be run from within a Fuchsia checkout or fx-worktree. It locates the checkout via $FUCHSIA_DIR (or by searching upward from the current directory for .jiri_manifest / .jiri_root) and uses jiri project to locate the local Git repository for each Gerrit project.origin/main, and uncommitted edits, staged changes, local branches, a detached HEAD, or local commits have no effect on the tool. All simulations run in memory against the target branch tip using git merge-tree --write-tree.jiri update or git fetch beforehand. fx revert queries origin (git ls-remote) for the current tip of the change‘s target branch and fetches any missing commit objects directly by SHA with an empty refmap (--refmap= and --no-write-fetch-head). If origin cannot be reached (e.g. offline), it prints a warning and falls back to the local copy of the change’s branch: origin/main, jiri/head, or HEAD for main, and origin/<branch> or the local <branch> for any other branch (e.g. releases/f30). If the branch is not available locally, the tool fails instead of simulating against main. In that case, jiri update is only required if the reverted commit itself is missing from local history (or is newer than the local branch). When offline, the conflict simulation only sees commits present in the local fallback ref.git fetch --unshallow or jiri update to fetch the missing history.gob-curl when it is installed. Otherwise fx revert prints a warning and falls back to plain curl with ~/.netrc and ~/.gitcookies; requests to internal hosts or authenticated endpoints may fail without valid cookies.--refmap=, --no-write-fetch-head, and automatic maintenance disabled never modifies HEAD, FETCH_HEAD, local or remote-tracking refs (refs/heads/*, refs/remotes/*, refs/tags/*), reflogs, packed-refs, the Git index, or the working tree, and never triggers jj colocation imports. Only content-addressed Git objects are added under .git/objects/.Always preview the revert plan before executing. Running without --upload only prints the plan (dry-run mode is the default):
fx revert <gerrit_url> --dry-run
Example:
fx revert https://fuchsia-review.googlesource.com/c/fuchsia/+/1783117 \ -m "Reverting suspect CL due to builder failure of core.arm64-debug" \ -f "go/bbid/8672361213915190673" \ -b "12345" \ --dry-run
Upload the revert to Gerrit with Rubber Stamper reviewer:
fx revert <gerrit_url> \ -m "<reason>" \ -f "<failure_link>" \ -b "<bug_id>" \ --upload
The full plan summary is always printed before any Gerrit API calls are made.
To automatically set Fuchsia-Auto-Submit +1 on the created revert CL:
fx revert <gerrit_url> \ -m "Reverting broken build" \ -f "go/bbid/..." \ --upload \ --auto-submit
<gerrit_url>: Positional (Required). Full Gerrit URL to the change (e.g. https://fuchsia-review.googlesource.com/c/fuchsia/+/123456).-m, --reason: Custom reason for the revert in the commit message.-f, --failure-link: Link to builder failure, log, or test failure (e.g. go/bbid/... or https://ci.chromium.org/...).-b, --bug: Associated Buganizer issue tracker ID (e.g. 12345 or b/12345).--upload: Create and upload the revert CL via Gerrit REST API with Rubber Stamper reviewer. Without this flag, the tool runs in dry-run mode.--dry-run: Preview the planned revert without executing API calls.--auto-submit: Apply Fuchsia-Auto-Submit +1 vote to the created revert CL (default: off).-h, --help: Display usage and help information.Run unit tests via fx bazel test:
fx bazel test --config=host //tools/revert:host_tests