refactor(core): introduce CommandContext for the queue+freeze prelude#1441
Conversation
This was referenced May 19, 2026
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced May 19, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
32628b4 to
d7feae3
Compare
32cbcd9 to
c542b1f
Compare
Member
Author
Revision history
|
Every `queue` and `freeze` command opens with the same four-line
ritual: resolve repository slug, resolve token, resolve API URL,
build a Mergify-flavored HTTP client. Wrap those into a
`CommandContext::resolve(...)` constructor + `ctx.mergify_client()`
builder living in a new `mergify_core::command_context` module.
The eight queue/freeze command preludes shrink from
let repository = auth::resolve_repository(opts.repository)?;
let token = auth::resolve_token(opts.token)?;
let api_url = auth::resolve_api_url(opts.api_url)?;
let client = HttpClient::new(api_url, token, ApiFlavor::Mergify)?;
to
let ctx = CommandContext::resolve(opts.repository, opts.token, opts.api_url)?;
let client = ctx.mergify_client()?;
`auth::resolve_*` stay public for the specialized callers that
don't fit the shape: `config validate` needs no repository,
`config simulate` derives the repo from a PR URL, `ci scopes-send`
resolves the repo from CI-env vars (different fallback chain).
Those keep wiring up the lower-level helpers by hand.
Net `-73 / +63` across 9 files; conceptually the bigger win is
that "the prelude of a Mergify command" is now a named concept
with one fix-it-once point.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I1b272570f6802dd13438c3d9baf26709b196574d
d7feae3 to
bdea5bb
Compare
c542b1f to
141fec6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every
queueandfreezecommand opens with the same four-lineritual: resolve repository slug, resolve token, resolve API URL,
build a Mergify-flavored HTTP client. Wrap those into a
CommandContext::resolve(...)constructor +ctx.mergify_client()builder living in a new
mergify_core::command_contextmodule.The eight queue/freeze command preludes shrink from
to
auth::resolve_*stay public for the specialized callers thatdon't fit the shape:
config validateneeds no repository,config simulatederives the repo from a PR URL,ci scopes-sendresolves the repo from CI-env vars (different fallback chain).
Those keep wiring up the lower-level helpers by hand.
Net
-73 / +63across 9 files; conceptually the bigger win isthat "the prelude of a Mergify command" is now a named concept
with one fix-it-once point.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1439