diff --git a/.changeset/long-queens-boil.md b/.changeset/long-queens-boil.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/long-queens-boil.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/README.md b/README.md index ddaf6c024..8533f5b11 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Hunk auto-detects Jujutsu and Sapling checkouts, so `hunk diff [revset]` and `hu hunk diff before.ts after.ts # compare two files directly hunk diff before.ts after.ts --watch # auto-reload when either file changes git diff --no-color | hunk patch - # review a patch from stdin +gh pr diff 123 --patch | hunk patch - # review a GitHub PR without checking it out ``` Watch mode remains continuous. Direct-file and Git-backed reviews normally use filesystem observation to refresh promptly, with periodic polling retained as a fallback for missed events or unavailable watchers. Jujutsu and Sapling reviews currently use polling rather than filesystem observation. diff --git a/website/src/content/docs/docs/workflows/files-and-patches.md b/website/src/content/docs/docs/workflows/files-and-patches.md index 2e421586e..6dea4bae4 100644 --- a/website/src/content/docs/docs/workflows/files-and-patches.md +++ b/website/src/content/docs/docs/workflows/files-and-patches.md @@ -34,3 +34,26 @@ git diff --no-color | hunk patch - Use `-` to make stdin explicit. Stdin is a snapshot, so it cannot use `--watch`; write the patch to a file when you need continuous reloads. Patch-like input is parsed into the same file and hunk model as repository input. Non-diff text belongs in [pager mode](/docs/workflows/git-pager-and-difftool/), where Hunk can fall back to plain text. + +## Review a GitHub pull request + +Because patch mode accepts any unified diff on stdin, you can review a pull request without checking it out by piping the [GitHub CLI](https://cli.github.com): + +```bash +gh pr diff 123 --patch | hunk patch - +``` + +If you review pull requests often, wrap it in a small shell function in your `.bashrc`/`.zshrc`: + +```bash +hunk-pr() { + gh pr diff "$1" --patch "${@:2}" | hunk patch - +} +``` + +```bash +hunk-pr 123 +hunk-pr 123 --repo owner/repo +``` + +The same pattern works for any forge tool that can emit a unified diff, such as `glab mr diff` for GitLab.