Skip to content

Instantly share code, notes, and snippets.

@dgageot
Created April 16, 2010 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dgageot/368980 to your computer and use it in GitHub Desktop.
Save dgageot/368980 to your computer and use it in GitHub Desktop.
#!/bin/bash
function parse_git_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=$(parse_git_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 != $(parse_git_branch) ]; then
git checkout $BRANCH
if [ $BRANCH != $(parse_git_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
@etienneCharignon
Copy link

Just a test of gitHub comment :
I would rather have named parse_git_branch => find_current_branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment