]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/ceph-backport.sh: better error message when cherry-pick fails
authorNathan Cutler <ncutler@suse.com>
Tue, 3 Sep 2019 13:57:53 +0000 (15:57 +0200)
committerNathan Cutler <ncutler@suse.com>
Thu, 5 Sep 2019 11:07:21 +0000 (13:07 +0200)
Signed-off-by: Nathan Cutler <ncutler@suse.com>
src/script/ceph-backport.sh

index 8f57b5b86a8346e81c840cfe2071a7a39e91b1b1..e729fd4231f2550b67747c1df4ff2667487d4e25 100755 (executable)
@@ -273,15 +273,31 @@ function prepare {
     debug "Fetching latest commits from ${original_pr_url}"
     git fetch $ceph_repo pull/$original_pr/head:pr-$original_pr
 
-    debug "Cherry picking $number commits from ${original_pr_url} into local branch $local_branch"
-    debug "If this operation does not succeed, you will need to resolve the conflicts manually"
+    info "Attempting to cherry pick $number commits from ${original_pr_url} into local branch $local_branch"
     let offset=$number-1 || true # don't fail on set -e when result is 0
-    for ((i=$offset; i>=0; i--))
-    do
-        debug "Cherry-picking commit $(git log --oneline --max-count=1 --no-decorate)"
-        git cherry-pick -x "pr-$original_pr~$i"
+    for ((i=$offset; i>=0; i--)) ; do
+        debug "Cherry-picking commit $(git log --oneline --max-count=1 --no-decorate pr-$original_pr~$i)"
+        if git cherry-pick -x "pr-$original_pr~$i" ; then
+            true
+        else
+            if [ "$verbose" ] ; then
+                git status
+            fi
+            error "Cherry pick failed"
+            info "Next, manually fix conflicts and complete the current cherry-pick"
+            if [ "$i" -gt "0" ] ; then
+                info "Then, cherry-pick the remaining commits from ${original_pr_url}, i.e.:"
+                for ((j=$i-1; j>=0; j--)) ; do
+                    info "-> missing commit: $(git log --oneline --max-count=1 --no-decorate pr-$original_pr~$j)"
+                done
+                info "Finally, re-run the script without --prepare"
+            else
+                info "Then re-run the script without --prepare"
+            fi
+            exit 1
+        fi
     done
-    info "Cherry picked $number commits from ${original_pr_url} into local branch $local_branch"
+    info "Cherry picking completed without conflicts"
 }
 
 if git show-ref HEAD >/dev/null 2>&1 ; then