-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update get_version_from_git.sh script
- Loading branch information
1 parent
94973b4
commit e9a7dc6
Showing
1 changed file
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
#!/bin/sh | ||
TAG=$(git describe --tags --abbrev=0 2>/dev/null) | ||
SUFFIX=$(git show -s --format=%ct.%h HEAD) | ||
TAG=$(git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1) | ||
|
||
if [ -n "${TAG}" ]; then | ||
COMMITS_SINCE_TAG=$(git rev-list ${TAG}.. --count) | ||
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then | ||
SUFFIX="dev${COMMITS_SINCE_TAG}.${SUFFIX}" | ||
fi | ||
if [ -z "${TAG}" ]; then | ||
echo "Could not find any tag" 1>&2 | ||
exit 1 | ||
else | ||
TAG="0" | ||
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count) | ||
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then | ||
COMMIT_INFO=$(git show -s --format=%ct.%h HEAD) | ||
SUFFIX="+git.${COMMITS_SINCE_TAG}.${COMMIT_INFO}" | ||
fi | ||
fi | ||
|
||
echo "${TAG}+git.${SUFFIX}" | ||
echo "${TAG}${SUFFIX}" |