]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-backport.sh: better variable names in cherry_pick_phase
authorNathan Cutler <ncutler@suse.com>
Mon, 21 Oct 2019 19:34:18 +0000 (21:34 +0200)
committerNathan Cutler <ncutler@suse.com>
Wed, 23 Oct 2019 11:00:30 +0000 (13:00 +0200)
Two of the variables used were not declared as local.

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

index 7dd9d0a5d31b852e2baacc3378f97c60fa7737bd..8b6753c84e1ff2cd827822693e7d4f0302b954d1 100755 (executable)
@@ -122,7 +122,9 @@ function check_tracker_status {
 }
 
 function cherry_pick_phase {
+    local number_of_commits=
     local offset=0
+    local singular_or_plural_commit=
     populate_original_issue
     if [ -z "$original_issue" ] ; then
         error "Could not find original issue"
@@ -141,11 +143,10 @@ function cherry_pick_phase {
 
     debug "Counting commits in ${original_pr_url}"
     remote_api_output=$(curl --silent https://api.github.com/repos/ceph/ceph/pulls/${original_pr}?access_token=${github_token})
-    number=$(echo ${remote_api_output} | jq .commits)
-    singular_or_plural_commit=
-    if [ "$number" -eq "$number" ] 2>/dev/null ; then
-        # \$number is an integer
-        if [ "$number" -eq "1" ] ; then
+    number_of_commits=$(echo ${remote_api_output} | jq .commits)
+    if [ "$number_of_commits" -eq "$number_of_commits" ] 2>/dev/null ; then
+        # \$number_of_commits is set, and is an integer
+        if [ "$number_of_commits" -eq "1" ] ; then
             singular_or_plural_commit="commit"
         else
             singular_or_plural_commit="commits"
@@ -154,7 +155,7 @@ function cherry_pick_phase {
         error "Could not determine the number of commits in ${original_pr_url}"
         bail_out_github_api "$remote_api_output"
     fi
-    info "Found $number $singular_or_plural_commit in $original_pr_url"
+    info "Found $number_of_commits $singular_or_plural_commit in $original_pr_url"
 
     debug "Fetching latest commits from $upstream_remote"
     git fetch $upstream_remote
@@ -170,8 +171,8 @@ function cherry_pick_phase {
     debug "Fetching latest commits from ${original_pr_url}"
     git fetch $upstream_remote pull/$original_pr/head:pr-$original_pr
 
-    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
+    info "Attempting to cherry pick $number_of_commits commits from ${original_pr_url} into local branch $local_branch"
+    let offset=${number_of_commits}-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 pr-$original_pr~$i)"
         if git cherry-pick -x "pr-$original_pr~$i" ; then