1515 detectPreviousVersion.sh
1616
1717SYNOPSIS
18- ${0##*/ } [-hvc ]
18+ ${0##*/ } [-hvcnd ]
1919
2020DESCRIPTION
2121 Detects most recent version tag of the repository.
@@ -30,10 +30,9 @@ DESCRIPTION
3030
3131 -c Prints the commit hash instead of the detected version to stdout.
3232
33- -m Enables mono-repo mode, allowing matching against semvers prefixed with
34- a product name. Eg: 'cool-app_1.2.3'
35-
36- -n The product name to match against. EG: 'bob' would match tags like 'bob_1.2.3'.
33+ -n Enables mono-repo mode allowing the product name to match against tags.
34+ EG: 'bob' would match tags like 'bob_1.2.3'.
35+ TIP: dir names and product names should match. This arg exists in case they do not.
3736
3837 -d The directory of the product to version. EG: 'path/to/bob'.
3938
6665# --------------------------------------------------------------------------------------------------
6766
6867OPTIND=1
69- while getopts " hv9cmn :d:" opt; do
68+ while getopts " hv9cn :d:" opt; do
7069 case $opt in
7170 h)
7271 printHelp
@@ -81,10 +80,6 @@ while getopts "hv9cmn:d:" opt; do
8180 9)
8281 arg_9=' set'
8382 ;;
84- m)
85- arg_m=' set'
86- arg_opts=" $arg_opts -m"
87- ;;
8883 n)
8984 arg_n=' set'
9085 arg_n_val=" $OPTARG "
@@ -113,10 +108,10 @@ tsCmd='date --utc +%FT%T.%3NZ'
113108
114109if [[ -n $arg_9 ]]; then
115110 semverRegex=" ^[v]?(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)$"
116- [[ -n $arg_m ]] && semverRegex=" ([0-9A-Za-z]+)?[_-]?[v]?(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)$"
111+ [[ -n $arg_d ]] && semverRegex=" ([0-9A-Za-z]+)?[_-]?[v]?(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)$"
117112else
118113 semverRegex=" ^[v]?(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)(\\ -([0-9A-Za-z]+))?(\\ +((([1-9])|([1-9][0-9]+))))?$"
119- [[ -n $arg_m ]] && semverRegex=" ^([0-9A-Za-z]+)?[_-]?[v]?(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)(\\ -([0-9A-Za-z]+))?(\\ +((([1-9])|([1-9][0-9]+))))?$"
114+ [[ -n $arg_d ]] && semverRegex=" ^([0-9A-Za-z]+)?[_-]?[v]?(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)(\\ -([0-9A-Za-z]+))?(\\ +((([1-9])|([1-9][0-9]+))))?$"
120115fi
121116
122117relative_path=" $( dirname " ${BASH_SOURCE[0]} " ) "
0 commit comments