Skip to content

Commit ff2bf89

Browse files
committed
add script
1 parent 79325d7 commit ff2bf89

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

script/early-access/create-branch

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# [start-readme]
4+
#
5+
# This script is run on a writer's machine to create an Early Access branch that matches the current docs-internal branch.
6+
#
7+
# [end-readme]
8+
9+
set -e
10+
11+
# Get current branch name
12+
currentBranch=$(git rev-parse --abbrev-ref HEAD)
13+
14+
if [ $currentBranch == "main" ]; then
15+
echo "You cannot run this script on the 'main' branch. Checkout a new branch first."
16+
exit 0
17+
fi
18+
19+
# Go up a directory
20+
pushd .. > /dev/null
21+
22+
if [ ! -d "docs-early-access" ]; then
23+
echo "A 'docs-early-access' directory does not exist! Run script/early-access/clone-locally first."
24+
popd > /dev/null
25+
exit 0
26+
fi
27+
28+
# Navigate to docs-early-access
29+
cd docs-early-access
30+
31+
# Check out main and update
32+
git checkout main
33+
git pull origin main
34+
35+
# Creat a branch with the current docs-internal branch name
36+
git checkout -b $currentBranch
37+
38+
# Go back to the previous working directory
39+
popd > /dev/null
40+
41+
echo -e "\nDone! Created a branch called ${currentBranch}. Remember to commit your work in ../docs-early-access when you're ready."

0 commit comments

Comments
 (0)