File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ main () {
1010 command=" $GIT_VER_APP_DIR /git-ver-$1 "
1111
1212 if [[ -f $command ]]; then
13- export GIT_VER_REPO_ROOT=" $( get_repo_root) "
14- export GIT_VER_REPO_VERSION =" $( get_version ) "
15- export GIT_VER_REPO_LATEST_TAG =" $( get_tag ) "
16- export GIT_VER_REPO_BRANCH_NAME =" $( get_branch_name ) "
13+ export GIT_VER_REPO_ROOT=" $( get_repo_root) "
14+ export GIT_VER_REPO_BRANCH_NAME =" $( get_branch_name ) "
15+ export GIT_VER_REPO_VERSION =" $( get_version ) "
16+ export GIT_VER_REPO_LATEST_TAG =" $( get_tag ) "
1717 bash $command ${*: 2}
1818 else
1919 echo >&2 " Unknown command: $1 ."
Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ get_tag_suffix() {
5353}
5454
5555get_tag () {
56+ local tag=" "
5657 if [[ " $GIT_VER_REPO_LATEST_TAG " == " " ]]; then
5758 local my_branch=" $( get_branch_name) "
58- local my_suffix=" $( get_suffix_from_branch_name $branch ) "
59- echo $( git name-rev $my_branch --name-only --refs=v* $my_suffix * )
59+ local my_suffix=" $( get_suffix_from_branch_name $my_branch ) "
60+ tag= " $( git name-rev $my_branch --name-only --refs=v* $my_suffix * | sed -s ' s/undefined//g ' ) "
6061 else
61- echo " $GIT_VER_REPO_LATEST_TAG "
62+ tag= $GIT_VER_REPO_LATEST_TAG
6263 fi
64+ echo $tag
6365}
6466
6567get_version () {
@@ -124,7 +126,7 @@ get_rev() {
124126 local suffix=$( get_branch_suffix)
125127 local last_tag=" $( get_tag) "
126128 local last_tag_ref=$( git rev-list --no-walk --max-count=1 --tags=v* $suffix * )
127-
129+
128130 if [[ " $last_tag_ref " == " " ]]; then
129131 rev=0
130132 else
@@ -133,7 +135,7 @@ get_rev() {
133135
134136 # extract the rev (if any) from the current tag.
135137 local rft=$( echo $last_tag | sed -e ' s/\(.*[-].*\)\([r][0-9]\)/\2/' | sed -e ' s/[^0-9]//g' )
136- if [[ " $rtf " == " " ]]; then rft=0; fi
138+ if [[ " $rft " == " " ]]; then rft=0; fi
137139 rev=$( expr $rsl + $rft )
138140 fi
139141
@@ -213,6 +215,7 @@ export -f get_patch
213215export -f get_minor
214216export -f get_major
215217export -f get_rev
218+ export -f get_tag
216219export -f get_semver
217220export -f is_in_git_repo
218221export -f get_repo_root
You can’t perform that action at this time.
0 commit comments