-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit
executable file
·40 lines (32 loc) · 910 Bytes
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
help() { printf "
*******
init.sh
*******
checks for a semver versioning tag in current git repo. if absent, initializes
it at 0.0.0. if present, doesn't do anything.
options:
\t-q --quiet : suppresses debug prints
\t-h --help : prints this text
usage/example:
\t./init.sh -q : runs this script in quiet mode
";
}
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then help; exit 1; fi;
if [[ $* == *-q* ]] || [[ $* == *--quiet* ]]; then exec 6>&1; exec > /dev/null; fi;
INITIAL_VERSION="0.0.0";
GET_LATEST_COMMAND="$(dirname $0)/get-latest -q";
CURRENT_VERSION=$($GET_LATEST_COMMAND);
if [[ $? = 1 ]]; then
git tag ${INITIAL_VERSION};
printf "
!: semver versioning not found from list of git tags...
\t> initialized repository versioning with 0.0.0.
";
else
printf "
latest semver version ${CURRENT_VERSION} found in git tags...
skipping initialization.
";
fi;
exit 0;