Skip to content

Commit 7385a5e

Browse files
exported get_tag. fixed bugs
1 parent ac122bb commit 7385a5e

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/git-ver

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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."

src/git-ver.bashlib

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ get_tag_suffix() {
5353
}
5454

5555
get_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

6567
get_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
213215
export -f get_minor
214216
export -f get_major
215217
export -f get_rev
218+
export -f get_tag
216219
export -f get_semver
217220
export -f is_in_git_repo
218221
export -f get_repo_root

0 commit comments

Comments
 (0)