Skip to content

Commit 0068dae

Browse files
Merge pull request #2 from jason-c-daniels/feature/pull-version-from-release-branch-name
Checking if the current branch name starts with release.
2 parents 85e3800 + f6cf7e6 commit 0068dae

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/git-ver-get-suffix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ get_suffix() {
2424

2525
if [[ "$branch_name" == master ]]; then
2626
suffix=""
27-
elif [[ "$branch_name" == "release/"* ]]; then
27+
elif [[ "$branch_name" == "release"* ]]; then
2828
suffix="rc"
29-
elif [[ "$branch_name" == develop ]]; then
30-
suffix="pre"
31-
elif [[ "$branch_name" == "feature/"* ]]; then
32-
suffix="beta";
33-
else
29+
elif [[ "$branch_name" == "develop"* ]]; then
30+
suffix="beta"
31+
elif [[ "$branch_name" == "feature"* ]]; then
3432
suffix="alpha";
33+
else
34+
suffix="pre";
3535
fi
3636

3737
if [[ ( "$1" == "--rev" || "$1" == "-r" ) && "$rev" -gt 0 && "$suffix" != "" ]]; then suffix="$suffix+r$rev"; fi

src/git-ver-get-version

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
set -e
33
ver=$(echo "$(git rev-parse --symbolic --tags | sed -e 's/\(.*\)\([-].*\)/\1/')" | sed 's/[^0-9.]//g' | sort -i | tail -1 )
44

5-
if [[ "$APPVEYOR" == true ]]; then
5+
branch_name=$(git rev-parse --abbrev-ref HEAD)
6+
if [[ "$branch_name" == "release"* ]]; then
7+
ver="$( git rev-parse --abbrev-ref HEAD | sed -e 's/[^0-9.]//g')"
8+
elif [[ "$APPVEYOR" == true ]]; then
69
ver=$APPVEYOR_BUILD_VERSION
710
elif [[ "$VersionPrefix" != "" ]]; then
811
ver=$VersionPrefix
912
elif [[ "$Version" != "" ]]; then
1013
ver=$Version
1114
fi
15+
1216
if [[ "$ver" == "" ]]; then ver="0.0.1"; fi
1317
echo $ver

src/git-ver-help-get-suffix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ To establish a suffix, the following steps are taken.
2424
3. If no tag suffix is extract, the branch name is used instead.
2525
4. The master branch gets no suffix. Only actual releases happen from it.
2626
5. A branch with a name starting with release gets the suffix of -rc
27-
6. A branch with a name starting with develop gets the suffix of -pre
28-
7. A branch with a name starting with feature gets the suffix of -beta
29-
8. All other branches get a suffix of -alpha
27+
6. A branch with a name starting with develop gets the suffix of -beta
28+
7. A branch with a name starting with feature gets the suffix of -alpha
29+
8. All other branches get a suffix of -pre
3030
3131
There are two additional optional meta data parameters.
3232
-r | --rev : This includes the results of git-ver get-rev as metadata after the main part of the suffix. For example: -rc+5

src/git-ver-help-get-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ If a suitable version is extracted from a tag it becomes the candidate version n
2727
1. An APP_VEYOR_VERSION environment variable is set.
2828
2. OR A VersionPrefix environment variable is set.
2929
3. OR A Version environment variable is set.
30+
4. OR The current branch name starts with release
3031
3132
The contents of the environment variable are assumed to match the MAJOR.MINOR.PATCH format. Ensure that they do.
3233

0 commit comments

Comments
 (0)