feat(rust): add mergify-core foundation types (Phase 1.2a)#1280
Conversation
|
This pull request is part of a Mergify stack:
|
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
8f404aa to
27194e6
Compare
8f2f3d5 to
f1c0421
Compare
Revision history
|
f1c0421 to
56ba494
Compare
56ba494 to
1b5b259
Compare
There was a problem hiding this comment.
Pull request overview
Adds the initial “foundation types” to mergify-core needed by ported Rust commands, covering structured exit codes, a top-level CLI error type, and a JSON/human output abstraction.
Changes:
- Introduce
exit_code::ExitCodewith fixed numeric values matching the documented contract (with code2reserved for clap usage errors). - Add
error::CliErrorwith a deterministicCliError -> ExitCodemapping. - Add
output::Outputtrait andStdioOutputimplementation (plus unit tests) to centralize JSON vs human rendering and stdout/stderr discipline.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mergify-core/src/output.rs | Introduces output abstraction + stdio implementation + tests for JSON/human behavior |
| crates/mergify-core/src/lib.rs | Exposes the new core modules and re-exports key types |
| crates/mergify-core/src/exit_code.rs | Defines structured exit codes and tests for locked numeric values |
| crates/mergify-core/src/error.rs | Defines CliError and its stable mapping to ExitCode with tests |
| crates/mergify-core/Cargo.toml | Adds serde/serde_json/thiserror dependencies for the new modules |
| Cargo.lock | Records the new Rust dependencies in the lockfile |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7617830 to
6c4294a
Compare
1b5b259 to
ddfcde3
Compare
ddfcde3 to
56033c1
Compare
56033c1 to
9d30ade
Compare
91c97d0 to
b10a54b
Compare
|
@jd this pull request is now in conflict 😩 |
Populates ``mergify-core`` with the three type-system pieces every ported command will depend on: - ``exit_code::ExitCode`` — typed mirror of Python's ``ExitCode`` enum with the locked numeric values from docs/exit-codes.md. Code 2 is reserved for clap argument errors, matching Python's Click reservation. - ``error::CliError`` — top-level error enum with deterministic ``exit_code()`` mapping. Today it covers Configuration, InvalidState, StackNotFound, Conflict, Generic, and Io variants; HTTP and Git variants land alongside their implementations in 1.2b / 1.2d. - ``output::Output`` trait + ``StdioOutput`` impl — commands emit through a trait object so the ``--json`` vs human rendering decision is a single place (stdout purity invariant from Phase 0.3 enforced by construction). Tests capture output via ``Arc<Mutex<Vec<u8>>>`` sinks. Deferred to separate PRs so each is reviewable in isolation: - 1.2b ``mergify-core::http`` — reqwest wrapper, retry, typed errors - 1.2c colored/spinner affordances on top of ``StdioOutput`` - 1.2d ``GitOps`` trait (only needed for stack commands) - Config loading, interactive prompts — added as ported commands demand them 7 unit tests cover the locked exit-code values, the ``CliError -> ExitCode`` mapping, and the JSON/human split. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: If50b81bb5d0accf1d80c25dc14ed259b30135895
9d30ade to
6eae5c0
Compare
Merge Queue Status
This pull request spent 7 minutes 23 seconds in the queue, including 7 minutes 5 seconds running CI. Required conditions to merge
|
Populates
mergify-corewith the three type-system pieces everyported command will depend on:
exit_code::ExitCode— typed mirror of Python'sExitCodeenum with the locked numeric values from docs/exit-codes.md. Code
2 is reserved for clap argument errors, matching Python's Click
reservation.
error::CliError— top-level error enum with deterministicexit_code()mapping. Today it covers Configuration,InvalidState, StackNotFound, Conflict, Generic, and Io variants;
HTTP and Git variants land alongside their implementations in
1.2b / 1.2d.
output::Outputtrait +StdioOutputimpl — commands emitthrough a trait object so the
--jsonvs human renderingdecision is a single place (stdout purity invariant from Phase
0.3 enforced by construction). Tests capture output via
Arc<Mutex<Vec<u8>>>sinks.Deferred to separate PRs so each is reviewable in isolation:
mergify-core::http— reqwest wrapper, retry, typed errorsStdioOutputGitOpstrait (only needed for stack commands)demand them
7 unit tests cover the locked exit-code values, the
CliError -> ExitCodemapping, and the JSON/human split.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com