Skip to content

Playbooks for g

Story-style workflows—solo, team, and on-call. Jump into the full Use cases page anytime.

github

Minimal GitHub REST API wrapper for stacked-PR operations and review comments.

auto-generated This page is built from //! comments in the Rust source. Edit the source and run npm run docs:extract to update it.

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 origin remote 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 loop with break to walk paginated API responses.
  • The json! macro for ergonomic JSON body construction.

Source: src/github/mod.rs