Skip to content
Merged
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
20 changes: 20 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ A small Rust toolbox, installed as `cgwalters-forge-misctool`.
```sh
cargo install --path crates/misctool
cgwalters-forge-misctool gh-pr-checks OWNER/REPO#123
cgwalters-forge-misctool operator-issue-diff OWNER/REPO#123
```

`gh-pr-checks` runs `gh pr checks` once and keeps its output and exit
status (0 passing, 1 failed, 8 pending). Install and authenticate the GitHub CLI
first, or provide `GH_TOKEN` in the environment. It does not poll, write to
GitHub or manage credentials. `--help` works without authentication.

`operator-issue-diff OWNER/REPO#N` reads an issue body's edit history
(GraphQL `userContentEdits`) through `gh api graphql` and prints a unified diff
between the last two revisions, with control characters escaped. It exits 0
when they match or there are fewer than two edits (and says so), 1 when the
body changed, and 2 on errors such as a bad reference, a failed query, a
deleted revision or an edit history that does not end at the current body.
Like `gh-pr-checks` it only reads, using gh's authentication or `GH_TOKEN`.

```sh
cgwalters-forge-misctool acp-tools [--json] [--timeout SECONDS] -- ADAPTER [ARGS...]
```
Expand Down
1 change: 1 addition & 0 deletions crates/misctool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ rust-version.workspace = true
chrono = { version = "0.4", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
similar = "3.2.1"
5 changes: 3 additions & 2 deletions crates/misctool/src/gh_pr_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Uses gh's existing authentication (including GH_TOKEN). Output is passed
through unchanged. Exit codes follow gh pr checks: 0 success, 1 failure,
8 pending; invocation errors use 2. No polling or writes are performed.";

fn parse_target(target: &str) -> Result<(&str, u64), String> {
let invalid = || "expected OWNER/REPO#N with a positive pull request number".to_string();
pub(crate) fn parse_target(target: &str) -> Result<(&str, u64), String> {
let invalid =
|| "expected OWNER/REPO#N with a positive issue or pull request number".to_string();
let (repo, number) = target.rsplit_once('#').ok_or_else(invalid)?;
let (owner, name) = repo.split_once('/').ok_or_else(invalid)?;
// A repository argument is data, not a gh option, host or URL.
Expand Down
9 changes: 6 additions & 3 deletions crates/misctool/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod acp_tools;
mod gh_pr_checks;
mod operator_issue_diff;
mod review_corpus;

use std::process::ExitCode;
Expand All @@ -9,9 +10,10 @@ const HELP: &str = "Small, read-only tools for operator workflows.
Usage: cgwalters-forge-misctool <COMMAND>

Commands:
acp-tools -- ADAPTER... List the commands an ACP adapter offers
gh-pr-checks OWNER/REPO#N Show a pull request's checks using gh
review-corpus Collect public review feedback or summarize JSONL
acp-tools -- ADAPTER... List the commands an ACP adapter offers
gh-pr-checks OWNER/REPO#N Show a pull request's checks using gh
operator-issue-diff OWNER/REPO#N Diff the last two edits of an issue body
review-corpus Collect public review feedback or summarize JSONL

Options:
-h, --help Print help
Expand All @@ -30,6 +32,7 @@ fn run() -> Result<u8, String> {
}
Some("acp-tools") => acp_tools::run(&args[1..]),
Some("gh-pr-checks") => gh_pr_checks::run(&args[1..]),
Some("operator-issue-diff") => operator_issue_diff::run(&args[1..]),
Some("review-corpus") => review_corpus::run(&args[1..]),
_ => Err(format!("expected a subcommand; use --help\n\n{HELP}")),
}
Expand Down
Loading
Loading