Skip to content

merge queue: embarking main (bd7a116), #1316 and #1298 together#1319

Closed
mergify[bot] wants to merge 4 commits intomainfrom
mergify/merge-queue/a6cd6a15ca
Closed

merge queue: embarking main (bd7a116), #1316 and #1298 together#1319
mergify[bot] wants to merge 4 commits intomainfrom
mergify/merge-queue/a6cd6a15ca

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Apr 29, 2026

🎉 This pull request has been checked successfully and will be merged soon. 🎉

Branch main (bd7a116), #1316 and #1298 are embarked together for merge.

This pull request has been created by Mergify to speculatively check the mergeability of #1298.
You don't need to do anything. Mergify will close this pull request automatically when it is complete.

Required conditions of queue rule default for merge:

Required conditions to stay in the queue:

---
checking_base_sha: 6e4808b45c93d8fbacb5f8da2488e1e934b89a47
previous_failed_batches: []
pull_requests:
  - number: 1298
    scopes: []
scopes: []
...

jd and others added 4 commits April 29, 2026 14:22
`CommandError.__str__` decoded captured stdout as strict UTF-8, so any
non-UTF-8 bytes from a subprocess (legacy locales, binary diff fragments,
truncated multi-byte sequences) would turn `str(error)` into a
`UnicodeDecodeError`. Every error-formatting site is affected — the
top-level CLI handler in `cli.py:104`, log messages, etc. — converting
the failure into an unhandled traceback instead of a clean message.

Switch to `decode(errors="replace")`. Invalid bytes become the U+FFFD
replacement character; all other formatting is preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: I3e3fd853218a6c4294b17e9529794320288124e5
Completes the config pilot. Second native command, flipped in
PORT_STATUS.toml from ``shimmed`` to ``native``.

## What ports natively

``mergify config simulate PULL_REQUEST_URL [-f PATH] [-t TOKEN] [-u URL]``:

1. Parses the PR URL into ``(owner/repo, number)``. Invalid URLs
   are rejected by clap's ``value_parser``, which exits 2 (matching
   Python's ``click.BadParameter``).
2. Resolves the config file (same three-location search as
   ``config validate`` — shared helper in ``paths.rs``).
3. Reads the YAML as a raw string (no parsing — the simulator API
   accepts the text verbatim).
4. Resolves the bearer token: explicit ``--token`` → ``MERGIFY_TOKEN``
   → ``GITHUB_TOKEN`` → error. Matches Python's precedence; the
   ``gh auth token`` subprocess fallback isn't ported yet.
5. Resolves the API URL: explicit ``--api-url`` → ``MERGIFY_API_URL``
   → ``https://api.mergify.com`` default.
6. POSTs ``{"mergify_yml": <content>}`` to
   ``/v1/repos/<repo>/pulls/<number>/simulator`` via the 1.2b HTTP
   client (auth + retry + typed errors).
7. Prints the returned title + summary to stdout.

Rich Markdown rendering of ``summary`` is deliberately deferred —
we print raw Markdown today. Human output drift is allowed by the
compat contract; machine-readable paths aren't affected because
``config simulate`` has no ``--json`` flag in Python either.

## Dispatch

``mergify-cli/src/main.rs`` now carries two clap subcommands
(``validate`` + ``simulate``). The dispatch logic got a light
reshape: on clap parse failure we distinguish "obvious native
intent" (argv contains ``config`` + one of ``validate``/``simulate``)
from "unrecognized command, fall through". Native-intent parse
errors surface clap's formatted error and exit 2; anything else
falls through to the Python shim so unported commands keep working.

## Refactor

The config-path resolver moved from ``validate.rs`` into a shared
``paths.rs`` module so both commands share a single source of
truth for the ``[".mergify.yml", ".mergify/config.yml",
".github/mergify.yml"]`` search list.

## Tests

24 tests in ``mergify-config`` (up from 11 in Phase 1.3):

- 3 for the shared path resolver (moved out of ``validate.rs``)
- 6 for PR URL parsing (happy path + 5 rejection cases)
- 4 for token resolution (explicit, env fallback, error)
- 2 for API URL resolution
- 1 end-to-end wiremock test: POST + JSON body + auth header +
  response rendering

Covered by the port-inventory guard: ``PORT_STATUS.toml`` flips
``config simulate`` from ``shimmed`` to ``native``.

Binary size: 8.0 MB → 8.3 MB (small bump from simulate.rs).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: If9194bb015c12c14cf71a9e831c4e1d67391793e
@mergify mergify Bot deployed to Mergify Merge Protections April 29, 2026 17:10 Active
@mergify mergify Bot closed this Apr 29, 2026
@mergify mergify Bot deleted the mergify/merge-queue/a6cd6a15ca branch April 29, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant