Skip to content

refactor(core): introduce CommandContext for the queue+freeze prelude#1441

Open
jd wants to merge 1 commit into
devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cdfrom
devs/jd/worktree-rust-port/introduce-commandcontext-queue-freeze-prelude--1b272570
Open

refactor(core): introduce CommandContext for the queue+freeze prelude#1441
jd wants to merge 1 commit into
devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cdfrom
devs/jd/worktree-rust-port/introduce-commandcontext-queue-freeze-prelude--1b272570

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 19, 2026

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

Depends-On: #1439

@jd
Copy link
Copy Markdown
Member Author

jd commented May 19, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 test(queue): add live smoke test for queue show #1408
2 feat(rust): port queue show to native Rust #1399
3 test(skill): port the skill-references test to Rust #1414
4 test(freeze): add live smoke test for freeze list #1434
5 feat(rust): port freeze list to native Rust #1435
6 test(freeze): add live smoke test for freeze create/update/delete #1436
7 feat(rust): port freeze create/update/delete to native Rust #1437
8 refactor(rust): dedupe emit-helper boilerplate across command crates #1438
9 refactor(rust): share test scaffolding via mergify-test-support crate #1439
10 refactor(core): introduce CommandContext for the queue+freeze prelude #1441 👈
11 refactor(ci): consolidate the CI-env scrubber into a shared testing module #1442
12 refactor: drop stale Phase X.Y doc markers and one inline color branch #1443
13 refactor(tui): share StyledGlyph across queue show/status renderers #1444
14 refactor(queue): drop indexmap, group_by_scope returns a Vec<(K, V)> #1445
15 refactor(ci): swap uuid for getrandom in the GHA heredoc delimiter #1446
16 refactor(config): standardize the workspace on serde_yaml_ng for YAML parsing #1447

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 19, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from 32628b4 to d7feae3 Compare May 19, 2026 13:04
@jd jd force-pushed the devs/jd/worktree-rust-port/introduce-commandcontext-queue-freeze-prelude--1b272570 branch from 32cbcd9 to c542b1f Compare May 19, 2026 13:04
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd
Copy link
Copy Markdown
Member Author

jd commented May 19, 2026

Revision history

# Type Changes Reason Date
1 initial 32cbcd9 2026-05-19 13:04 UTC
2 rebase 32cbcd9 → c542b1f (rebase only) 2026-05-19 13:04 UTC
3 rebase c542b1f → 141fec6 (rebase only) 2026-05-19 14:15 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 19, 2026 13:04 Failure
@mergify mergify Bot requested a review from a team May 19, 2026 13:19
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
@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from d7feae3 to bdea5bb Compare May 19, 2026 14:14
@jd jd force-pushed the devs/jd/worktree-rust-port/introduce-commandcontext-queue-freeze-prelude--1b272570 branch from c542b1f to 141fec6 Compare May 19, 2026 14:14
@jd jd temporarily deployed to func-tests-live May 19, 2026 14:15 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 19, 2026 14:15 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 19, 2026 14:15 Failure
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