Skip to content

Commit 6a19fde

Browse files
committed
Do not assume symbolic-ref exists
1 parent 36594e5 commit 6a19fde

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

commands/init

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ if [ -z "$VERSION" ]; then
2121
VERSION="$(git symbolic-ref --short HEAD)"
2222
fi
2323
fi
24+
if [ -z "$VERSION" ] && [ -n "$TRAVIS_BRANCH" ]; then
25+
VERSION="$TRAVIS_BRANCH"
26+
fi
2427
if [ -z "$VERSION" ]; then
2528
VERSION="v1"
2629
fi
@@ -46,8 +49,10 @@ if [ ! -e .git ] || [ -z "$NAME" ] || [ -z "$VERSION" ]; then
4649
git init
4750
fi
4851

49-
if [ "$(git symbolic-ref --short HEAD)" != "$VERSION" ]; then
50-
git checkout -b "$VERSION"
52+
if git symbolic-ref --short HEAD > /dev/null 2>&1; then
53+
if [ "$(git symbolic-ref --short HEAD)" != "$VERSION" ]; then
54+
git checkout -b "$VERSION"
55+
fi
5156
fi
5257

5358
if [ -n "$TRAVIS_BRANCH" ]; then

0 commit comments

Comments
 (0)