Skip to content

Commit ac122bb

Browse files
now reading version from /repo.version as a fallback
1 parent a95af24 commit ac122bb

18 files changed

+189
-78
lines changed

.vscode/settings.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"cSpell.words": [
3-
"repo"
3+
"Hmmss",
4+
"VEYOR",
5+
"YYMMDD",
6+
"YYYYMMDD",
7+
"bashlib",
8+
"elif",
9+
"hhmmss",
10+
"readlink",
11+
"repo",
12+
"semver",
13+
"toplevel"
414
]
515
}

repo.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

src/git-ver

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
#!/bin/bash
22
set -e
3-
export GIT_VER_VERSION="0.0.3-beta"
4-
export GIT_VER_DIR=$(dirname $(readlink -f $0))
3+
export GIT_VER_APP_VERSION="0.0.3-beta"
4+
export GIT_VER_APP_DIR=$(dirname $(readlink -f $0))
55
main () {
6-
source "$GIT_VER_DIR/git-ver.bashlib" #include the common library so everything in here can execute.
6+
source "$GIT_VER_APP_DIR/git-ver.bashlib" #include the common library so everything in here can execute.
77
if [[ $1 == version || $1 == help ]]; then
8-
bash "$GIT_VER_DIR/git-ver-$1" ${*:2}
8+
bash "$GIT_VER_APP_DIR/git-ver-$1" ${*:2}
99
elif [ "$(is_in_git_repo)" == true ]; then
10-
11-
command="$GIT_VER_DIR/git-ver-$1"
10+
command="$GIT_VER_APP_DIR/git-ver-$1"
1211

1312
if [[ -f $command ]]; then
14-
bash $command ${*:2}
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)"
17+
bash $command ${*:2}
1518
else
1619
echo >&2 "Unknown command: $1."
17-
bash "$GIT_VER_DIR/git-ver-help"
20+
bash "$GIT_VER_APP_DIR/git-ver-help"
1821
exit 1
1922
fi;
2023
else

src/git-ver-get-major

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
set -ex
2+
set -e
33
get_major $*

src/git-ver-get-repo-root

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
set -e
3+
get_repo_root $*

src/git-ver-get-semver

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
#!/bin/bash
22
set -e
3-
prefix="$(get_prefix)"
4-
suffix="$(get_suffix $1)"
5-
6-
if [[ "$suffix" != "" ]]; then
7-
semver="$prefix-$suffix"
8-
fi;
9-
10-
echo "$semver"
3+
get_semver $*

src/git-ver-help

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -e
33
if [[ "$1" == "" ]]; then
44
echo "
55
usage: git-ver [command] [command arguments]
6+
git ver [command] [command arguments]
7+
68
For more details on the individual commands type git-ver help [command]
79
810
List of known commands:
@@ -14,6 +16,8 @@ get-patch : Returns the patch number from the current semantic version number
1416
1517
get-prefix : Returns the version with a prefix, prefix defaults to 'v'
1618
19+
get-repo-root : Gets the full path to the root of the current repository
20+
1721
get-rev : Counts the number of commits from the last tag and returns that as a revision number. (placed in info as .rev#)
1822
1923
get-semver : Retrieves a full semantic version, optionally with metadata (+r1; +dYYYYMMDD-hhmmss)
@@ -26,8 +30,8 @@ help : Displays this help information.
2630
2731
"
2832
else
29-
if [[ -f "$GIT_VER_DIR/git-ver-help-$1" ]]; then
30-
( export GIT_VER_VERSION; "$GIT_VER_DIR/git-ver-help-$1" )
33+
if [[ -f "$GIT_VER_APP_DIR/git-ver-help-$1" ]]; then
34+
( export GIT_VER_APP_VERSION; "$GIT_VER_APP_DIR/git-ver-help-$1" )
3135
else
3236
echo >&2 "Couldn't find help for: $1.";
3337
exit 1;

src/git-ver-help-get-major

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -e
33
echo "
44
usage: git-ver get-major
5+
git ver get-major
6+
57
get-major : Returns the major number from the current semantic version number. (Maj.Min.Patch[-info+metadata])
68
79
This number is extracted from an internal call to git-ver get-version.

src/git-ver-help-get-minor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -e
33
echo "
44
usage: git-ver get-minor
5+
git ver get-minor
6+
57
get-minor : Returns the minor number from the current semantic version number.
68
79
This number is extracted from an internal call to git-ver get-version.

src/git-ver-help-get-patch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
set -e
33
echo "
44
usage: git-ver get-patch
5+
git ver get-patch
6+
7+
58
get-patch : Returns the patch number from the current semantic version number. (Maj.Min.Patch[-info+metadata])
69
710
This number is extracted from an internal call to git-ver get-version.

0 commit comments

Comments
 (0)