Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
debovema committed Jan 15, 2018
1 parent 35bbd47 commit 399928c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions mavenAutoRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ createReleaseTriggerBranch () {

createReleaseTriggerBranch_initCommandLineArguments $PARAMETERS

if [ $? -gt 0 ]; then
cleanUp
createReleaseTriggerBranch_usage
return 1
fi

echo
echo "Creating release trigger branch on repository $GIT_REPOSITORY_URL"
echo "-> source branch is $SOURCE_BRANCH"
Expand Down Expand Up @@ -115,10 +121,16 @@ createReleaseTriggerBranch () {
return 0
}

createReleaseTriggerBranch_usage () {
echo
echo "Usage is $0 URL [arg1] [arg2]"
}

createReleaseTriggerBranch_initCommandLineArguments () {
unset GIT_REPOSITORY_URL RELEASE_TRIGGER_BRANCH SOURCE_BRANCH GIT_PARENT_REPOSITORY_URL GIT_PARENT_PARENT_REPOSITORY_URL GIT_PARENT_PARENT_PARENT_REPOSITORY_URL

if [ "$#" -lt 1 ]; then
echo
echo " At least a Git repository URL is required" >&2
return 1
fi
Expand Down Expand Up @@ -200,6 +212,12 @@ updateReleaseVersionsAndTrigger () {

updateReleaseVersionsAndTrigger_initCommandLineArguments $PARAMETERS

if [ $? -gt 0 ]; then
cleanUp
updateReleaseVersionsAndTrigger_usage
return 1
fi

echo
echo "Releasing $GIT_REPOSITORY_URL, source branch is $SOURCE_BRANCH, release trigger branch is $RELEASE_TRIGGER_BRANCH"
echo
Expand Down Expand Up @@ -287,6 +305,11 @@ updateReleaseVersionsAndTrigger () {
return 0
}

updateReleaseVersionsAndTrigger_usage () {
echo
echo "Usage is $0 URL [arg1] [arg2]"
}

updateReleaseVersionsAndTrigger_initCommandLineArguments () {
unset RELEASE_VERSION DEV_VERSION GIT_USER_NAME GIT_USER_EMAIL GIT_REPOSITORY_URL INCREMENT_POLICY SOURCE_BRANCH RELEASE_TRIGGER_BRANCH

Expand Down Expand Up @@ -395,6 +418,8 @@ updateReleaseVersions () {
parseCommandLine () {
unset OPTS NO_BANNER NO_COMMAND_LINE_OVERRIDE RELEASE_TRIGGER_BRANCH

OLDPWD1=`pwd`

OPTS=`getopt -o '' -l no-banner,no-cmd-line-override,release-trigger-branch: -- "$@"`

if [ $? != 0 ]
Expand Down Expand Up @@ -425,15 +450,15 @@ parseCommandLine () {
PARAMETERS=$(echo $PARAMETERS | xargs)

simpleConsoleLogger "Maven auto releaser v$MAVEN_AUTO_RELEASER_VERSION" $NO_BANNER
simpleConsoleLogger " https://github.com/debovema/maven-auto-releaser" $NO_BANNER
simpleConsoleLogger " https://github.com/debovema/maven-auto-releaser/tree/$MAVEN_AUTO_RELEASER_VERSION_TAG" $NO_BANNER
}

cleanUp () {
# clean up and restore initial directory
if [ -d "$TEMP_CLONE_DIRECTORY" ]; then
echo
echo "== Clean up =="
cd $OLDPWD
cd $OLDPWD1
echo " Removing temporary directory: $TEMP_CLONE_DIRECTORY"
rm -rf $TEMP_CLONE_DIRECTORY
echo
Expand Down

0 comments on commit 399928c

Please sign in to comment.