Files
spring-data-build/etc/scripts/new-issue-branch
Greg Turnquist 04ac2a7f7b #184 - Improvements to new issue branch script
Removed the offline mode for the issue branch. If dependencies are missing it won't work offline either. Rename it to drop the .sh suffix. That way, we can change its language in the future without user having to know.

Original pull request: #185.
2015-10-05 18:25:30 +02:00

34 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
#
# This script creates a new local issue branch for the given issue id.
# Previous changes are stashed before the issue branch is created and are reapplied after branch creation.
#
# executing new-issue-branch.sh DATACMNS-42
# will create a new (local) branch issue/DATACMNS-42
USAGE="$0 <ticket_id>"
if [ $# -lt 1 ]; then echo -e "ERROR: ticket_id required. \n$USAGE" >&2; exit 1; fi
if [ $# -gt 1 ]; then echo -e "ERROR: One argument maximum.\n$USAGE" >&2; exit 1; fi
TICKET_ID=${1:?"TICKET_ID Parameter is missing!"}
OLD_VERSION_TMP=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '^\[.*')
OLD_POM_VERSION=${OLD_VERSION_TMP:?"Could not extract current project version from pom.xml"}
# Replaces BUILD in BUILD-SNAPSHOT with the given TICKET_ID
NEW_POM_VERSION=${OLD_POM_VERSION/"BUILD"/$TICKET_ID}
ISSUE_BRANCH="issue/$TICKET_ID"
echo "Creating feature branch $TICKET_ID: $OLD_POM_VERSION -> $NEW_POM_VERSION"
echo "Stashing potential intermediate changes..." && git stash\
&& git checkout -b $ISSUE_BRANCH\
&& $(mvn $MAVEN_FLAGS -q versions:set -DgenerateBackupPoms=false -DnewVersion=$NEW_POM_VERSION)\
&& ( \
(\
git commit -am "$TICKET_ID - Prepare branch"\
&& echo "Created feature branch: $ISSUE_BRANCH"\
&& echo "Reapplying potentially stashed changes... " && git stash pop)\
|| echo "Something went wrong!")