Skip to content

Commit 1a6a4e2

Browse files
committed
fix: use real GitHub CLI path instead of conflicting /usr/bin/gh
1 parent ea15e2d commit 1a6a4e2

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ This project extends the [Full Stack FastAPI Template](https://github.com/fastap
77
Submit as a **GitHub fork** of [full-stack-fastapi-template](https://github.com/fastapi/full-stack-fastapi-template) so reviewers get a web diff/PR:
88

99
```bash
10-
# One-time: GitHub CLI auth (or set GITHUB_TOKEN)
11-
gh auth login
10+
# One-time: GitHub CLI auth (use /usr/local/bin/gh — NOT /usr/bin/gh)
11+
/usr/local/bin/gh auth login
1212

1313
# Fork upstream, push this branch, open PR
1414
./scripts/setup-fork-and-pr.sh
1515
```
1616

17+
If `gh auth login` fails with `No such command "auth"`, your `gh` is the wrong package. Use `/usr/local/bin/gh` or install from https://cli.github.com.
18+
1719
Manual fork: https://github.com/fastapi/full-stack-fastapi-template/fork → then set `origin` to your fork and `git push -u origin main`.
1820

1921
Compare URL shape: `https://github.com/fastapi/full-stack-fastapi-template/compare/master...YOUR_USER:full-stack-fastapi-template:main`

scripts/setup-fork-and-pr.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ BASE_COMMIT="${BASE_COMMIT:-3f52abe}"
1010

1111
cd "${ROOT_DIR}"
1212

13+
gh_cli() {
14+
if [[ -x /usr/local/bin/gh ]] && /usr/local/bin/gh --version >/dev/null 2>&1; then
15+
/usr/local/bin/gh "$@"
16+
return
17+
fi
18+
if [[ -x "${HOME}/bin/gh" ]] && "${HOME}/bin/gh" --version >/dev/null 2>&1; then
19+
"${HOME}/bin/gh" "$@"
20+
return
21+
fi
22+
if command -v gh >/dev/null 2>&1 && gh --version >/dev/null 2>&1; then
23+
gh "$@"
24+
return
25+
fi
26+
echo "GitHub CLI not found. Install: https://cli.github.com" >&2
27+
echo "Note: /usr/bin/gh on some systems is NOT GitHub CLI." >&2
28+
exit 1
29+
}
30+
1331
get_github_token() {
1432
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
1533
echo "${GITHUB_TOKEN}"
@@ -19,13 +37,17 @@ get_github_token() {
1937
echo "${GH_TOKEN}"
2038
return
2139
fi
40+
if gh_cli auth status >/dev/null 2>&1; then
41+
gh_cli auth token 2>/dev/null && return
42+
fi
2243
printf 'protocol=https\nhost=github.com\n\n' | git credential fill 2>/dev/null \
2344
| awk -F= '/^password=/{print $2; exit}'
2445
}
2546

2647
TOKEN="$(get_github_token || true)"
2748
if [[ -z "${TOKEN}" ]]; then
28-
echo "No GitHub token. Set GITHUB_TOKEN or run: gh auth login" >&2
49+
echo "No GitHub token. Run: /usr/local/bin/gh auth login" >&2
50+
echo "Or set GITHUB_TOKEN, then re-run this script." >&2
2951
echo "Manual fork: https://github.com/${UPSTREAM}/fork" >&2
3052
exit 1
3153
fi

0 commit comments

Comments
 (0)