From d0c2ce90bbf194995f331003f10852a29872f49f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 7 Dec 2018 22:03:57 +0000 Subject: [PATCH] Fix semver when git history is not present --- contrib/semver/name.sh | 4 ++-- contrib/semver/version.sh | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/semver/name.sh b/contrib/semver/name.sh index d749d3ff..9dbdca33 100644 --- a/contrib/semver/name.sh +++ b/contrib/semver/name.sh @@ -1,10 +1,10 @@ #!/bin/sh # Get the branch name, removing any "/" characters from pull requests -BRANCH=$(git symbolic-ref --short HEAD | tr -d "/" 2>/dev/null) +BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null | tr -d "/") # Check if the branch name is not master -if [ "$BRANCH" = "master" ]; then +if [ "$BRANCH" = "master" ] || [ $? != 0 ]; then printf "yggdrasil" exit 0 fi diff --git a/contrib/semver/version.sh b/contrib/semver/version.sh index 6eeffc5f..c23abf41 100644 --- a/contrib/semver/version.sh +++ b/contrib/semver/version.sh @@ -16,6 +16,11 @@ PATCH=$(git rev-list $TAG..master --count --merges --grep="from $DEVELOPBRANCH" if [ $? != 0 ]; then PATCH=$(git rev-list HEAD --count 2>/dev/null) + if [ $? != 0 ]; then + printf 'unknown' + exit -1 + fi + printf 'v0.0.%d' "$PATCH" exit -1 fi