Skip to content

Commit 0e8d0f4

Browse files
committed
checkout preview script
1 parent 43bcfd9 commit 0e8d0f4

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,23 @@ We take backwards-compatibility seriously and work hard to ensure you can rely o
475475

476476
We are keen for your feedback; please open an [issue](https://www.github.com/onkernel/hypeman-go/issues) with questions, bugs, or suggestions.
477477

478+
## Development
479+
480+
### Testing Preview Branches
481+
482+
When developing features in the main [hypeman](https://github.com/onkernel/hypeman) repo, Stainless automatically creates preview branches in `stainless-sdks/hypeman-go` with your API changes. You can check out these branches locally to test the SDK changes:
483+
484+
```bash
485+
# Checkout preview/<branch> (e.g., if working on "devices" branch in hypeman)
486+
./scripts/checkout-preview devices
487+
488+
# Checkout an exact branch name
489+
./scripts/checkout-preview -b main
490+
./scripts/checkout-preview -b preview/my-feature
491+
```
492+
493+
The script automatically adds the `stainless` remote if it doesn't exist.
494+
478495
## Contributing
479496

480497
See [the contributing documentation](./CONTRIBUTING.md).

scripts/checkout-preview

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
# Checkout a preview branch from the stainless-sdks mirror.
8+
#
9+
# Usage:
10+
# ./scripts/checkout-preview <branch> # Checkout preview/<branch>
11+
# ./scripts/checkout-preview -b <branch> # Checkout exact branch name
12+
13+
STAINLESS_REMOTE="git@github.com:stainless-sdks/hypeman-go.git"
14+
15+
usage() {
16+
echo "Usage: $0 [-b] <branch>"
17+
echo ""
18+
echo "Checkout a branch from the stainless-sdks/hypeman-go mirror."
19+
echo ""
20+
echo "Options:"
21+
echo " -b Use exact branch name instead of preview/<branch>"
22+
echo ""
23+
echo "Examples:"
24+
echo " $0 devices # Checkout preview/devices"
25+
echo " $0 -b main # Checkout main"
26+
echo " $0 -b preview/foo # Checkout preview/foo"
27+
exit 1
28+
}
29+
30+
ensure_stainless_remote() {
31+
if ! git remote get-url stainless >/dev/null 2>&1; then
32+
echo "==> Adding stainless remote..."
33+
git remote add stainless "${STAINLESS_REMOTE}"
34+
fi
35+
}
36+
37+
EXACT_BRANCH=false
38+
39+
while getopts "bh" opt; do
40+
case $opt in
41+
b) EXACT_BRANCH=true ;;
42+
h) usage ;;
43+
*) usage ;;
44+
esac
45+
done
46+
shift $((OPTIND - 1))
47+
48+
if [ $# -lt 1 ]; then
49+
usage
50+
fi
51+
52+
BRANCH="$1"
53+
54+
if [ "$EXACT_BRANCH" = false ]; then
55+
BRANCH="preview/${BRANCH}"
56+
fi
57+
58+
ensure_stainless_remote
59+
60+
echo "==> Fetching from stainless remote..."
61+
git fetch stainless
62+
63+
echo "==> Checking out ${BRANCH}..."
64+
git checkout -B "${BRANCH}" "stainless/${BRANCH}"
65+
66+
echo ""
67+
echo "Switched to branch '${BRANCH}' tracking stainless/${BRANCH}"

0 commit comments

Comments
 (0)