]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-backport.sh: restore "set -x" when in debug mode
authorNathan Cutler <ncutler@suse.com>
Tue, 19 Nov 2019 12:49:18 +0000 (13:49 +0100)
committerNathan Cutler <ncutler@suse.com>
Tue, 19 Nov 2019 12:53:21 +0000 (13:53 +0100)
Recently, "set -x"/"set +x" code was added to show the user which git commands
the script is running. This code was inadvertently deactivating "set -x" when
running in debug mode.

Signed-off-by: Nathan Cutler <ncutler@suse.com>
src/script/ceph-backport.sh

index bf276a7306d5975d2e01dad56cbd6b8bfb4dcc21..3ca96ab2c51f07ad49b06078f690fa86319f2acb 100755 (executable)
@@ -274,6 +274,7 @@ function cherry_pick_phase {
             fi
         else
             set +x
+            maybe_restore_set_x
             error "Cannot initialize $local_branch - local branch already exists"
             false
         fi
@@ -284,6 +285,7 @@ function cherry_pick_phase {
     git fetch "$upstream_remote" "pull/$original_pr/head:pr-$original_pr"
 
     set +x
+    maybe_restore_set_x
     info "Attempting to cherry pick $number_of_commits commits from ${original_pr_url} into local branch $local_branch"
     offset="$((number_of_commits - 1))" || true
     for ((i=offset; i>=0; i--)) ; do
@@ -292,8 +294,10 @@ function cherry_pick_phase {
         set -x
         if git cherry-pick -x "$sha1_to_cherry_pick" ; then
             set +x
+            maybe_restore_set_x
         else
             set +x
+            maybe_restore_set_x
             [ "$VERBOSE" ] && git status
             error "Cherry pick failed"
             info "Next, manually fix conflicts and complete the current cherry-pick"
@@ -791,6 +795,7 @@ function maybe_delete_deprecated_backport_common {
                 set -x
                 rm -f "$deprecated_backport_common"
                 set +x
+                maybe_restore_set_x
             fi
         fi
         if [ -e "$deprecated_backport_common" ] ; then
@@ -800,6 +805,12 @@ function maybe_delete_deprecated_backport_common {
     fi
 }
 
+function maybe_restore_set_x {
+    if [ "$DEBUG" ] ; then
+        set -x
+    fi
+}
+
 function maybe_update_pr_milestone_labels {
     local component
     local data_binary
@@ -1619,11 +1630,13 @@ if [ "$PR_PHASE" ] ; then
         set -x
         git checkout "$local_branch"
         set +x
+        maybe_restore_set_x
     fi
     
     set -x
     git push -u "$fork_remote" "$local_branch"
     set +x
+    maybe_restore_set_x
     
     original_issue=""
     original_pr=""