Skip to content

Commit 9d7cf81

Browse files
committed
checkout preview script
1 parent 977115e commit 9d7cf81

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,27 @@ hypeman [resource] [command] [flags]
6666

6767
- `--debug` - Enable debug logging (includes HTTP request/response details)
6868
- `--version`, `-v` - Show the CLI version
69+
70+
## Development
71+
72+
### Testing Preview Branches
73+
74+
When developing features in the main [hypeman](https://github.com/onkernel/hypeman) repo, Stainless automatically creates preview branches in `stainless-sdks/hypeman-cli` with your API changes. You can check out these branches locally to test the CLI changes:
75+
76+
```bash
77+
# Checkout preview/<branch> (e.g., if working on "devices" branch in hypeman)
78+
./scripts/checkout-preview devices
79+
80+
# Checkout an exact branch name
81+
./scripts/checkout-preview -b main
82+
./scripts/checkout-preview -b preview/my-feature
83+
```
84+
85+
The script automatically adds the `stainless` remote if it doesn't exist.
86+
87+
After checking out a preview branch, you can build and test the CLI:
88+
89+
```bash
90+
go build -o hypeman ./cmd/hypeman
91+
./hypeman --help
92+
```

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="[email protected]:stainless-sdks/hypeman-cli.git"
14+
15+
usage() {
16+
echo "Usage: $0 [-b] <branch>"
17+
echo ""
18+
echo "Checkout a branch from the stainless-sdks/hypeman-cli 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)