-
-
Save etienneCharignon/723516 to your computer and use it in GitHub Desktop.
Rename parse_git_branch to find_current_branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function find_current_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
if [ 0 -eq `git remote -v | grep -c push` ]; then | |
REMOTE_REPO=`git remote -v | sed 's/origin//'` | |
else | |
REMOTE_REPO=`git remote -v | grep "(push)" | sed 's/origin//' | sed 's/(push)//'` | |
fi | |
BRANCH=$(find_current_branch) | |
if [ -z "$1" ]; then | |
echo "No commit is performed since no comment is provided" | |
else | |
git add . | |
git commit -a -m "$1" | |
fi | |
git pull | |
if [ ! -d ".privatebuild" ]; then | |
git clone . .privatebuild | |
fi | |
cd .privatebuild | |
if [ $BRANCH != $(find_current_branch) ]; then | |
git checkout $BRANCH | |
if [ $BRANCH != $(find_current_branch) ]; then | |
git checkout --track -b $BRANCH origin\/$BRANCH | |
fi | |
fi | |
git fetch | |
git reset --hard origin\/$BRANCH | |
git clean -xdf | |
if [ -e "pom.xml" ]; then | |
export MAVEN_OPTS="-Xmx2G -XX:MaxPermSize=256m" | |
if (`mvn --help | grep -e '--threads' > /dev/null`); then | |
echo "Using // Build in Maven" | |
mvn -T 0.5C install -PfullPackage | |
else | |
mvn install -PfullPackage | |
fi | |
if [ $? -eq 0 ]; then | |
if [ "$1" != "no-push" ]; then | |
echo "Publishing to: $REMOTE_REPO" | |
git push $REMOTE_REPO $BRANCH | |
fi | |
else | |
echo "Unable to build" | |
exit $? | |
fi | |
else | |
echo "Could not find pom.xml" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment