#!/bin/bash LOG_FILE="../merge.log" build_host="sprygo" build_dir="/scratch/sfr/next" build_cmd="bin/build_next" no_build=false [ "$1" = "-n" ] && { shift no_build=true } [ -n "$1" ] && build_host="$1" cp /dev/null $LOG_FILE log() { echo "$@" | tee -a $LOG_FILE } execute() { log "$" $@ $@ 2>&1 | tee -a $LOG_FILE return ${PIPESTATUS[0]} } execute git checkout master execute git reset --hard stable heads=$(grep -v '^#' ../real_control | awk -F ' ' '$2=="quilt" { printf("quilt/%s ", $3); } $2=="git" { printf("%s/%s ", $3, $5); }') for h in $heads; do log Merging $h old_head=$(git rev-parse HEAD) execute git merge $h || { echo Merge failed 1>&2 bash -i || exit GIT_EDITOR=: execute git commit -v -a execute git diff -M --stat --summary 'HEAD^..' } new_head=$(git rev-parse HEAD) [ "$old_head" = "$new_head" ] && continue $no_build && continue rsync -avH --exclude .git --delete . "$build_host":"$build_dir"/. || { echo Rsync failed 1>&2 bash -i || exit } ssh "$build_host" "$build_cmd" || { echo Build failed 1>&2 bash -i || exit } done exit 0