Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 49 additions & 1 deletion crates/mergify-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use mergify_config::simulate::SimulateOptions;
use mergify_core::OutputMode;
use mergify_core::StdioOutput;
use mergify_queue::pause::PauseOptions;
use mergify_queue::status::StatusOptions;
use mergify_queue::unpause::UnpauseOptions;

fn main() -> ExitCode {
Expand Down Expand Up @@ -55,6 +56,7 @@ enum NativeCommand {
CiQueueInfo,
QueuePause(QueuePauseOpts),
QueueUnpause(QueueUnpauseOpts),
QueueStatus(QueueStatusOpts),
}

struct ConfigSimulateOpts {
Expand Down Expand Up @@ -89,6 +91,14 @@ struct QueueUnpauseOpts {
api_url: Option<String>,
}

struct QueueStatusOpts {
repository: Option<String>,
token: Option<String>,
api_url: Option<String>,
branch: Option<String>,
output_json: bool,
}

/// Heuristic: does argv look like the user intended a native
/// subcommand?
///
Expand All @@ -104,7 +114,7 @@ fn looks_native(argv: &[String]) -> bool {
(pair[0].as_str(), pair[1].as_str()),
("config", "validate" | "simulate")
| ("ci", "scopes-send" | "git-refs" | "queue-info")
| ("queue", "pause" | "unpause"),
| ("queue", "pause" | "unpause" | "status"),
)
})
}
Expand Down Expand Up @@ -216,6 +226,18 @@ fn detect_native(argv: &[String]) -> Option<NativeCommand> {
token,
api_url,
})),
Subcommands::Queue(QueueArgs {
repository,
token,
api_url,
command: QueueSubcommand::Status(StatusCliArgs { branch, json }),
}) => Some(NativeCommand::QueueStatus(QueueStatusOpts {
repository,
token,
api_url,
branch,
output_json: json,
})),
}
}

Expand Down Expand Up @@ -294,6 +316,19 @@ fn run_native(cmd: NativeCommand) -> ExitCode {
)
.await
}
NativeCommand::QueueStatus(opts) => {
mergify_queue::status::run(
StatusOptions {
repository: opts.repository.as_deref(),
token: opts.token.as_deref(),
api_url: opts.api_url.as_deref(),
branch: opts.branch.as_deref(),
output_json: opts.output_json,
},
&mut output,
)
.await
}
}
});

Expand Down Expand Up @@ -465,6 +500,8 @@ enum QueueSubcommand {
Pause(PauseCliArgs),
/// Unpause the merge queue for the repository.
Unpause,
/// Show merge queue status for the repository.
Status(StatusCliArgs),
}

#[derive(clap::Args)]
Expand All @@ -478,3 +515,14 @@ struct PauseCliArgs {
#[arg(long = "yes-i-am-sure", default_value_t = false)]
yes_i_am_sure: bool,
}

#[derive(clap::Args)]
struct StatusCliArgs {
/// Filter the queue by branch name.
#[arg(long, short = 'b')]
branch: Option<String>,

/// Emit the raw API response as a single JSON document.
#[arg(long, default_value_t = false)]
json: bool,
}
5 changes: 4 additions & 1 deletion crates/mergify-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ publish = false

[dependencies]
mergify-core = { path = "../mergify-core" }
anstyle = "1"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
indexmap = "2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
url = "2"

[dev-dependencies]
serde_json = "1.0"
temp-env = { version = "0.3", features = ["async_closure"] }
tokio = { version = "1", default-features = false, features = ["macros", "rt", "time"] }
wiremock = "0.6"
Expand Down
13 changes: 8 additions & 5 deletions crates/mergify-queue/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//! Native Rust implementation of the `mergify queue` subcommands.
//!
//! Phase 1.5 ports `pause` and `unpause` — two idempotent API
//! calls that rest on the HTTP client added in 1.2b and the new
//! Phase 1.5 ported `pause` and `unpause` — two idempotent API
//! calls that rest on the HTTP client added in 1.2b and the
//! `put`/`delete_if_exists` methods added alongside this crate.
//! `queue status` and `queue show` stay shimmed until their
//! JSON-output contracts are locked (they carry considerable
//! structured data and want careful schema work).
//! Phase 1.7 ports `status`, the read-only command that fetches
//! the merge-queue snapshot and renders it either as a JSON
//! passthrough or as the human-friendly batch tree + waiting list.
//! `queue show` stays shimmed until its conditions/checks tree
//! ports next.

pub mod pause;
pub mod status;
pub mod unpause;
Loading
Loading