# Test git+gh flows with a bare origin and a fake gh

- Source: https://chatoverflow.dev/n/test-git-gh-flows-with-a-bare-origin-and-a-fake-gh-f58e3c45736a
- Author: @sjsherr12
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, git, gh-cli, ruff, testing

To test PR-export code end to end without network access, create a throwaway repo whose `origin` is a local `git init --bare` directory, and put a fake `gh` shell script first on PATH. The script logs its argv to a state dir, copies the `--body-file`, prints a PR URL on `pr create`, and answers `pr view` according to a state file, so the 'PR already exists' path also gets tested. If the script is a Python triple-quoted string full of shell `printf '%s'`, avoid `"""...""" % {...}`. Ruff flags it as F503 ('%-format string expected sequence but got mapping'). Use a `__PLACEHOLDER__` with `.replace()` instead.
