]> git.ozlabs.org Git - next-scripts/commitdiff
do_merge: factor out manaul fix up points
authorStephen Rothwell <sfr@canb.auug.org.au>
Fri, 26 Jul 2019 05:46:47 +0000 (15:46 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 26 Jul 2019 05:46:47 +0000 (15:46 +1000)
do_merge

index 243fc50d8022163f60eebb9f64e714068141cb4d..2e3cf9ce7072970e1e49323d69a00ea0ddd780b3 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -33,6 +33,19 @@ execute()
        return "${PIPESTATUS[0]}"
 }
 
+fix_up()
+{
+       if [ -n "$1" ]; then
+               linux-next-notify "$1"
+       fi
+       if [ -n "$2" ]; then
+               printf '%s\n' "$2" 1>&2
+       fi
+       if ! bash -i; then
+               exit
+       fi
+}
+
 if [ -z "$start_from" ]; then
        cp /dev/null "$LOG_FILE"
        execute date -R
@@ -69,8 +82,7 @@ for h in $heads; do
        if [ -f "../pre-merge/$tree" ]; then
                while read -r p <&7; do
                        if ! "$bin_dir/do_patch" -n "$p"; then
-                               linux-next-notify "premerge patch failed"
-                               bash -i || exit
+                               fix_up "premerge patch failed"
                        fi 7<&-
                done 7<"../pre-merge/$tree"
        fi
@@ -83,17 +95,15 @@ for h in $heads; do
                check_unmerged_files "$tree"
 
                if git diff 2>&1 | grep -E -q '<<<<<|^\*'; then
-                       linux-next-notify "new conflict found merging $tree"
                        if [ -f "../merge-fixes/$tree" ]; then
                                echo "Merge fixes exist for this tree:"
                                cat "../merge-fixes/$tree"
                        fi
-                       bash -i || exit
+                       fix_up "new conflict found merging $tree"
                fi
 #              if [ "$(git status --porcelain)" ]; then
                        if ! execute git commit --no-edit -v -a; then
-                               linux-next-notify "next commit failed for $tree"
-                               bash -i || exit
+                               fix_up "next commit failed for $tree"
                        fi
                        execute git diff -M --stat --summary 'HEAD^..'
 #              fi
@@ -101,8 +111,7 @@ for h in $heads; do
        if [ -f "../merge-fixes/$tree" ]; then
                while read -r p <&7; do
                        if ! "$bin_dir/merge_fix" -n "$p"; then
-                               linux-next-notify "merge fix failed for $tree"
-                               bash -i || exit
+                               fix_up "merge fix failed for $tree"
                        fi 7<&-
                done 7<"../merge-fixes/$tree"
        fi
@@ -134,21 +143,15 @@ for h in $heads; do
 
        repo="${build_host:+$build_host:}${build_dir}"
        if ! git push -f "$repo" master:refs/heads/next; then
-               echo git push failed 1>&2
-               linux-next-notify "push failed for $tree"
-               bash -i || exit
+               fix_up "push failed for $tree" "git push failed"
        fi
 
        if [ -x "../pre-build/$tree" ] &&
           ! "../pre-build/$tree"; then
-               echo Prebuild script failed 1>&2
-               linux-next-notify "pre-build script failed for $tree"
-               bash -i || exit
+               fix_up "pre-build script failed for $tree" "Prebuild script failed"
        fi
        if ! "$bin_dir/do_build" "$tree"; then
-               echo Build failed 1>&2
-               linux-next-notify "build failed for $tree"
-               bash -i || exit
+               fix_up "build failed for $tree" "Build failed"
        fi
 
        need_build=false