]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-backport.sh: do not say "1 commits" 30725/head
authorNathan Cutler <ncutler@suse.com>
Mon, 7 Oct 2019 19:56:39 +0000 (21:56 +0200)
committerNathan Cutler <ncutler@suse.com>
Thu, 10 Oct 2019 12:22:28 +0000 (14:22 +0200)
Signed-off-by: Nathan Cutler <ncutler@suse.com>
src/script/ceph-backport.sh

index 595cbe68d6cbf17707baacc3e5b958ba04f10e9b..3f38e135b17b8ba5ea30cf5a78a16bdf63e93347 100755 (executable)
@@ -98,11 +98,19 @@ 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)
-    if [ -z "$number" -o "$number" = "null" ] ; then
+    singular_or_plural_commit=
+    if [ "$number" -eq "$number" ] 2>/dev/null ; then
+        # \$number is an integer
+        if [ "$number" -eq "1" ] ; then
+            singular_or_plural_commit="commit"
+        else
+            singular_or_plural_commit="commits"
+        fi
+    else
         error "Could not determine the number of commits in ${original_pr_url}"
         bail_out_github_api "$remote_api_output"
     fi
-    info "Found $number commits in ${original_pr_url}"
+    info "Found $number $singular_or_plural_commit in $original_pr_url"
 
     debug "Fetching latest commits from $upstream_remote"
     git fetch $upstream_remote