Skip to content

Instantly share code, notes, and snippets.

@jsuereth
Created December 6, 2011 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsuereth/1439541 to your computer and use it in GitHub Desktop.
Save jsuereth/1439541 to your computer and use it in GitHub Desktop.
Merge script to make sure develop commits actually build before pushing to master.
#!/bin/bash
# TODO - Create a branch by build number?
declare -r integration_branch="integration"
declare -r remote_devel_branch="develop"
declare -r remote_master_branch="master"
declare -r origin_url="git@github.com:scala/scala.git"
declare -r build_opts="all.clean test"
declare -r logfile="$(pwd)/integration.log"
function execute() {
echo "---------------------------------" >> $logfile
echo "> $@" >> $logfile
echo ""
$@ >> $logfile 2>&1
}
echo "Scala integration build @ $(date)..." > $logfile
# create the local repo if it doesn't exist.
if test ! -d scala; then
execute mkdir scala
fi
# Now update the branch and build.
pushd scala >/dev/null
if test ! -d .git; then
execute git init
execute git remote add origin $origin_url
fi
# Pull in all latest chagnes.
echo "Pulling latest commits..."
execute git fetch
# Remove old integration branch
if test "$(git branch 2>/dev/null | grep $integration_branch)" != ""; then
# TODO - We have to make sure we're not on the integration branch when we do this....
execute git checkout master
execute git branch -D $integration_branch
fi
# Create integration branch
echo "Merging $remote_devel_branch and $remote_master_branch into $integration_branch..."
execute git checkout origin/master
execute git checkout -b $integration_branch
execute git branch --track $integration_branch origin/$remote_master_branch
# TODO - better way to test this
if test "$(git diff origin/$remote_master_branch)" == ""; then
echo "-------------------------------------------"
echo " No changes to validate for master branch."
echo "-------------------------------------------"
exit 0
fi
# Try to merge with master first....
execute git pull origin $remote_master_branch
# Merge in latest changes.
execute git pull origin $remote_devel_branch
# build nightly
echo "Building Scala..."
ant $build_opts
# if successful, push new commits.
popd >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment