Skip to content

Commit 2100479

Browse files
committed
Fix wrong message if chekout from branch
Display branch name if repo not on tag Issue: #20
1 parent 0d81ee2 commit 2100479

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

hooks/post-checkout

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ if [ $TIME_AGO -gt $LAST_FETCH_TIME ]; then
3333
cd ${HOOKS_PATH}
3434
git fetch --tags
3535

36-
# Need gets tags from my styleguide-hooks repo, not local
3736
LAST_TAG=$(git tag -l | tail -n 1)
38-
CURRENT_TAG=$(git tag -l --points-at HEAD)
37+
CURRENT=$(git tag -l --points-at HEAD)
38+
if [ -z "${CURRENT}" ]; then
39+
CURRENT=$(git branch | grep '\*' | sed 's/\* //')
40+
fi
3941

40-
if [ "$LAST_TAG" == "$CURRENT_TAG" ]; then
42+
if [ "$LAST_TAG" == "$CURRENT" ]; then
4143
echo "styleguide-hooks up-to-date"
4244

43-
elif ask "Update from ${CURRENT_TAG} to ${LAST_TAG}?" Y; then
45+
elif ask "Checkout from ${CURRENT} to ${LAST_TAG}?" Y; then
4446
git checkout "${LAST_TAG}" 2>/dev/null && \
45-
echo "styleguide-hooks updated from ${CURRENT_TAG} to ${LAST_TAG}"
47+
echo "styleguide-hooks updated from ${CURRENT} to ${LAST_TAG}"
4648
fi
4749
cd - >/dev/null
4850
fi

0 commit comments

Comments
 (0)