Implement [shellcheck](https://www.shellcheck.net/) recommendations

This commit is contained in:
Ismo Vuorinen
2016-08-04 19:12:59 +03:00
parent eb4896403a
commit 0140b539f5

View File

@@ -10,6 +10,7 @@
# file in which to update version number # file in which to update version number
FILE_VERSION="VERSION" FILE_VERSION="VERSION"
# file to use as our change log
FILE_CHANGELOG="CHANGELOG.md" FILE_CHANGELOG="CHANGELOG.md"
NOW="$(date +'%Y-%m-%d')" NOW="$(date +'%Y-%m-%d')"
@@ -22,7 +23,7 @@ CYAN="\033[1;36m"
WHITE="\033[1;37m" WHITE="\033[1;37m"
RESET="\033[0m" RESET="\033[0m"
LATEST_HASH=`git log --pretty=format:'%h' -n 1` LATEST_HASH=$(git log --pretty=format:'%h' -n 1)
# current Git branch # current Git branch
BRANCH_CURRENT=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') BRANCH_CURRENT=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
@@ -50,7 +51,7 @@ fi
if [ ! -f $FILE_VERSION ]; then if [ ! -f $FILE_VERSION ]; then
echo -ne "${QUESTION_FLAG} ${CYAN}Can't find version file (${FILE_VERSION}), create one?" echo -ne "${QUESTION_FLAG} ${CYAN}Can't find version file (${FILE_VERSION}), create one?"
read RESPONSE read -r RESPONSE
if [[ $RESPONSE =~ [yY](es)* ]] || [ "$RESPONSE" = "" ]; then if [[ $RESPONSE =~ [yY](es)* ]] || [ "$RESPONSE" = "" ]; then
echo "0.0.0" > $FILE_VERSION echo "0.0.0" > $FILE_VERSION
else else
@@ -62,7 +63,7 @@ fi
if [ ! -f $FILE_CHANGELOG ]; then if [ ! -f $FILE_CHANGELOG ]; then
echo -ne "${QUESTION_FLAG} ${CYAN}Can't find changelog file (${FILE_CHANGELOG}), create one?" echo -ne "${QUESTION_FLAG} ${CYAN}Can't find changelog file (${FILE_CHANGELOG}), create one?"
read RESPONSE read -r RESPONSE
if [[ $RESPONSE =~ [yY](es)* ]] || [ "$RESPONSE" = "" ]; then if [[ $RESPONSE =~ [yY](es)* ]] || [ "$RESPONSE" = "" ]; then
echo "" > $FILE_CHANGELOG echo "" > $FILE_CHANGELOG
else else
@@ -71,13 +72,13 @@ if [ ! -f $FILE_CHANGELOG ]; then
fi fi
# Continue to guess new value for our version # Continue to guess new value for our version
BASE_STRING=`cat $FILE_VERSION` BASE_STRING=$(cat $FILE_VERSION)
if [ $BASE_STRING = "" ]; then if [ "$BASE_STRING" = "" ]; then
BASE_STRING="0.0.0" BASE_STRING="0.0.0"
fi fi
BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`) BASE_LIST=($(echo $BASE_STRING | tr '.' ' '))
V_MAJOR=${BASE_LIST[0]} V_MAJOR=${BASE_LIST[0]}
V_MINOR=${BASE_LIST[1]} V_MINOR=${BASE_LIST[1]}
V_PATCH=${BASE_LIST[2]} V_PATCH=${BASE_LIST[2]}
@@ -91,59 +92,59 @@ V_PATCH=$((V_PATCH + 1))
SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH" SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH"
echo -ne "${QUESTION_FLAG} ${CYAN}Enter a version number [${WHITE}$SUGGESTED_VERSION${CYAN}]: " echo -ne "${QUESTION_FLAG} ${CYAN}Enter a version number [${WHITE}$SUGGESTED_VERSION${CYAN}]: "
read NEW_VERSION read -r NEW_VERSION
if [ "$NEW_VERSION" = "" ]; then if [ "$NEW_VERSION" = "" ]; then
NEW_VERSION=$SUGGESTED_VERSION NEW_VERSION=$SUGGESTED_VERSION
fi fi
echo -e "${NOTICE_FLAG} Will set new version to be ${WHITE}$NEW_VERSION" echo -e "${NOTICE_FLAG} Will set new version to be ${WHITE}$NEW_VERSION"
echo "" echo ""
echo -ne "${WARNING_FLAG} This is the last chance to bail out before anything has happened." echo -ne "${WARNING_FLAG} This is the last chance to bail out before anything has happened."
read read -r
# Set up our release branch name # Set up our release branch name
BRANCH_RELEASE=release-$NEW_VERSION BRANCH_RELEASE=release-$NEW_VERSION
# create the release branch from the -develop branch # create the release branch from the -develop branch
git checkout -b $BRANCH_RELEASE $BRANCH_DEV git checkout -b "$BRANCH_RELEASE" "$BRANCH_DEV"
# Set our new version to our version file # Set our new version to our version file
echo $NEW_VERSION > $FILE_VERSION echo "$NEW_VERSION" > "$FILE_VERSION"
# Create our changelog # Create our changelog
echo "## $NEW_VERSION ($NOW)" > tmpfile echo "## $NEW_VERSION ($NOW)" > tmpfile
git log --pretty=format:" - %h %ad | %s%d [%an]" --date=short --no-merges "$BASE_STRING"...HEAD >> tmpfile git log --pretty=format:" - %h %ad | %s%d [%an]" --date=short --no-merges "$BASE_STRING"...HEAD >> tmpfile
echo "" >> tmpfile echo "" >> tmpfile
echo "" >> tmpfile echo "" >> tmpfile
cat $FILE_CHANGELOG >> tmpfile cat "$FILE_CHANGELOG" >> tmpfile
mv tmpfile $FILE_CHANGELOG mv tmpfile $FILE_CHANGELOG
echo -e "$ADJUSTMENTS_MSG" echo -e "$ADJUSTMENTS_MSG"
read read -r
echo -e "$PUSHING_MSG" echo -e "$PUSHING_MSG"
# Make sure changes have been added # Make sure changes have been added
git add $FILE_VERSION $FILE_CHANGELOG git add "$FILE_VERSION" "$FILE_CHANGELOG"
# Commit version number increment # Commit version number increment
git commit -am "Incrementing version number to $NEW_VERSION" git commit -am "Incrementing version number to $NEW_VERSION"
# Merge release branch with the new version number into master # Merge release branch with the new version number into master
git checkout $BRANCH_MASTER git checkout "$BRANCH_MASTER"
git merge --no-ff $BRANCH_RELEASE git merge --no-ff "$BRANCH_RELEASE"
# Create tag for new version from -master # Create tag for new version from -master
git tag -am "Tag version ${NEW_VERSION}." "$NEW_VERSION" git tag -am "Tag version ${NEW_VERSION}." "$NEW_VERSION"
# Merge release branch with the new version number back into develop # Merge release branch with the new version number back into develop
git checkout $BRANCH_DEV git checkout "$BRANCH_DEV"
git merge --no-ff $BRANCH_RELEASE git merge --no-ff "$BRANCH_RELEASE"
# Remove release branch # Remove release branch
git branch -d $BRANCH_RELEASE git branch -d "$BRANCH_RELEASE"
echo -ne "${QUESTION_FLAG} ${CYAN}Push?" echo -ne "${QUESTION_FLAG} ${CYAN}Push?"
read PUSH read -r PUSH
if [[ $PUSH =~ [yY](es)* ]] || [ "$PUSH" = "" ]; then if [[ $PUSH =~ [yY](es)* ]] || [ "$PUSH" = "" ]; then
git push --all origin git push --all origin
fi fi