METRON-2348 prepare-commit broken by github api change (ottobackwards) closes apache/metron#1580
diff --git a/dev-utilities/committer-utils/README.md b/dev-utilities/committer-utils/README.md
index 0a91759..f0f358f 100644
--- a/dev-utilities/committer-utils/README.md
+++ b/dev-utilities/committer-utils/README.md
@@ -28,6 +28,8 @@
 
 In the following example, I enter the pull request number when prompted.   Using the pull request number, the script can extract most of the remaining required information.
 
+> prepare-commit utilizes [jq](https://stedolan.github.io/jq/) to parse the github api returns, so it is required
+
 1. Execute the script.  
 
     The first time the script is run, you will be prompted for additional information including your Apache username, Apache email, and Github username.  These values are persisted in `~/.metron-prepare-commit`.  Subsequent executions of the script will retrieve these values, rather than prompting you again for them.
diff --git a/dev-utilities/committer-utils/metron-committer-common b/dev-utilities/committer-utils/metron-committer-common
index 257bcb0..88dc576 100644
--- a/dev-utilities/committer-utils/metron-committer-common
+++ b/dev-utilities/committer-utils/metron-committer-common
@@ -128,9 +128,15 @@
     fi
 
     # ensure that the pull request exists
-    PR_EXISTS=$(curl -sI https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | grep Status: | sed 's/[^0-9]//g')
-    if [[ "$PR_EXISTS" != "200" ]]; then
-      echo "Error: pull request #$PR does not exist"
+    PR_STATE=$(curl -s https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | jq ".state")
+    PR_MERGEABLE=$(curl -s https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | jq ".mergeable_state")
+    if [[ "$PR_STATE" != "\"open\"" ]]; then
+      echo "Error: pull request #$PR is not open or does not exist"
+      exit 1
+    fi
+
+    if [[ "$PR_MERGEABLE" != "\"clean\"" ]] && [[ "$PR_MERGEABLE" != "\"unstable\"" ]]; then
+      echo "Error: pull request #$PR is not mergable. mergeable_state is $PR_MERGEABLE"
       exit 1
     fi
 }