X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=merge_fix;h=9048251a23ab422c5be3df87d12c2a6ce82c36c5;hb=HEAD;hp=e7c749c9bca285a65fa5c6f85942e9b285880a60;hpb=22780d27c0a1f3bbaf428129e7af6972bce1d625;p=next-scripts diff --git a/merge_fix b/merge_fix index e7c749c..9048251 100755 --- a/merge_fix +++ b/merge_fix @@ -1,21 +1,18 @@ #!/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 } patch="$1" +shift [ -f "$patch" ] || { echo "patch does not exist" 1>&2 exit 1 } -[ -n "$2" ] && build_host="$2" + +. "$(dirname $0)/common.sh" log() { @@ -29,14 +26,29 @@ execute() return ${PIPESTATUS[0]} } +old_head=$(git rev-parse HEAD) execute git am -3 "$patch" || { echo "git am failed" 1>&2 bash -i || exit } +new_head=$(git rev-parse HEAD) +[ "$old_head" = "$new_head" ] && { + echo "hmmm, looks like the patch was already applied or is unneeded" + exit 0 +} +[ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] && { + echo "hmmm, committed soemthing, but diff is empty" 1>&2 + bash -i || exit +} + GIT_EDITOR=: execute git reset 'HEAD^' || { echo "git reset failed" 1>&2 bash -i || exit } +execute git add -A . || { + echo "git add failed" 1>&2 + bash -i || exit +} GIT_EDITOR=: execute git commit -v -a --amend || { echo "git commit failed" 1>&2 bash -i || exit @@ -44,13 +56,12 @@ GIT_EDITOR=: execute git commit -v -a --amend || { $no_build && exit 0 -rsync -avH --exclude .git --delete . "$build_host":"$build_dir"/. || { - echo Rsync failed 1>&2 +git push -f "${build_host}${build_host:+:}${build_dir}" master:refs/heads/next || { + echo git push failed 1>&2 bash -i || exit } -echo "Building using $build_cmd on $build_host" -ssh "$build_host" "$build_cmd" || { +"$bin_dir/do_build" || { echo Build failed 1>&2 bash -i || exit }