]> git.ozlabs.org Git - next-scripts/blobdiff - merge_fix
Add more tools
[next-scripts] / merge_fix
diff --git a/merge_fix b/merge_fix
new file mode 100755 (executable)
index 0000000..e7c749c
--- /dev/null
+++ b/merge_fix
@@ -0,0 +1,58 @@
+#!/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"
+[ -f "$patch" ] || {
+       echo "patch does not exist" 1>&2
+       exit 1
+}
+[ -n "$2" ] && build_host="$2"
+
+log()
+{
+       echo "$@" | tee -a $LOG_FILE
+}
+
+execute()
+{
+       log "$" $@
+       $@ 2>&1 | tee -a $LOG_FILE
+       return ${PIPESTATUS[0]}
+}
+
+execute git am -3 "$patch" || {
+       echo "git am failed" 1>&2
+       bash -i || exit
+}
+GIT_EDITOR=: execute git reset 'HEAD^' || {
+       echo "git reset failed" 1>&2
+       bash -i || exit
+}
+GIT_EDITOR=: execute git commit -v -a --amend || {
+       echo "git commit failed" 1>&2
+       bash -i || exit
+}
+
+$no_build && exit 0
+
+rsync -avH --exclude .git --delete . "$build_host":"$build_dir"/. || {
+       echo Rsync failed 1>&2
+       bash -i || exit
+}
+
+echo "Building using $build_cmd on $build_host"
+ssh "$build_host" "$build_cmd" || {
+       echo Build failed 1>&2
+       bash -i || exit
+}
+
+exit 0