From f74dd0f6e0a6c243ae1ff5eb896baec16d389902 Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Tue, 3 Sep 2019 15:57:53 +0200 Subject: [PATCH] script/ceph-backport.sh: better error message when cherry-pick fails Signed-off-by: Nathan Cutler --- src/script/ceph-backport.sh | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/script/ceph-backport.sh b/src/script/ceph-backport.sh index 8f57b5b86a8..e729fd4231f 100755 --- a/src/script/ceph-backport.sh +++ b/src/script/ceph-backport.sh @@ -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 -- 2.39.5