22
33GIT_BRANCH=$( git branch --show-current)
44
5- if [[ " master" != " $GIT_BRANCH " ]]; then
6- echo " Release will be made from branch $GIT_BRANCH ."
7- sleep 5
8- fi
9-
5+ CHECK_FOR_CLEAN_BRANCH=true
106
11- if [[ -n $( git cherry -v) ]]; then
12- echo " Detected unpushed commits. Exit"
13- exit 1
14- fi
15-
16- if [[ -n $( git status --porcelain --untracked-files=no) ]]; then
17- echo " Uncommitted changes detected. Exit"
18- exit 1
19- fi
20-
21- while getopts " v:" opt; do
7+ while getopts " v:c" opt; do
228 case $opt in
9+ c)
10+ echo " Not checking for clean branch (-c)"
11+ CHECK_FOR_CLEAN_BRANCH=false
12+ ;;
2313 v)
24- echo " Changing parent pom version to: $OPTARG " >&2
14+ echo " Changing parent pom version to: $OPTARG "
2515 mvn versions:set -DnewVersion=" ${OPTARG} " -DupdateMatchingVersions=false
2616 ;;
2717 ? )
@@ -31,6 +21,26 @@ while getopts "v:" opt; do
3121 esac
3222done
3323
24+ if [[ " $CHECK_FOR_CLEAN_BRANCH " = true ]]; then
25+ echo " Checking for clean git checkout. Disable with '-c'"
26+ if [[ " master" != " $GIT_BRANCH " ]]; then
27+ echo " Not on 'master' branch. You have 5 seconds to abort."
28+ sleep 5
29+ fi
30+
31+ if [[ -n $( git cherry -v) ]]; then
32+ echo " Detected unpushed commits. Exit"
33+ exit 1
34+ fi
35+
36+ if [[ -n $( git status --porcelain --untracked-files=no) ]]; then
37+ echo " Uncommited changes detected. Exit"
38+ exit 1
39+ fi
40+ else
41+ echo " Not checking for clean branch CHECK_FOR_CLEAN_BRANCH=$CHECK_FOR_CLEAN_BRANCH "
42+ fi
43+
3444
3545# replace module -SNAPSHOT version with release version (non-SNAPSHOT)
3646mvn versions:set -DremoveSnapshot
0 commit comments