Minimal GitHub REST API wrapper for stacked-PR operations and review comments.
Tutorial overview
This module handles all communication with GitHub’s REST API. It focuses on the operations needed for the “Stacked PRs” workflow and the “public bucket” of the review-comment system:
- Detecting the repository owner/name from the
originremote URL. - Finding existing open PRs for a branch.
- Creating new PRs that target the correct base branch.
- Updating the base branch of an existing PR when the stack is reorganised.
- Posting review comments on a PR (the “public” bucket of the two-bucket review model; private notes live in the local SQLite DB instead).
It uses ureq for simple, synchronous (blocking) HTTP requests and
serde_json for building and parsing JSON payloads.
Rust concepts used here
Result<(String, String)>for returning multiple values on success.- String manipulation (
trim_start_matches,splitn) to parse remote URLs. - A custom
struct([PrInfo]) for grouping related API response data. - A
loopwithbreakto walk paginated API responses. - The
json!macro for ergonomic JSON body construction.
Source:
src/github/mod.rs