userid-validation: adapt to new gerrit email permission

The latest gerrit no longer allows users without account modification
permissions to look up users with secondary email addresses. So if
someone uploads a commit to gerrit using a secondary email, this script
no longer can determine if they are approved.

Utilize the gerrit query command to look up the username of a commit.

Tested:
- Confirmed that with this change that a previously failing autobump
  commit was properly given the ok-to-test +1

Change-Id: Ia44149bb4605261bb3451d4f491051df7fd0bbd4
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/jenkins/userid-validation b/jenkins/userid-validation
index 97938f2..2082269 100755
--- a/jenkins/userid-validation
+++ b/jenkins/userid-validation
@@ -20,20 +20,7 @@
 
 echo "Checking ${GERRIT_PROJECT}:${GERRIT_BRANCH}:${GERRIT_CHANGE_ID}:${GERRIT_PATCHSET_REVISION}"
 
-# shellcheck disable=2086 # GERRIT_COMMAND is purposefully wordsplit.
-COMMITTER_EMAIL=$(${GERRIT_COMMAND}/a/changes/${GERRIT_PROJECT/\//%2F}~${GERRIT_BRANCH}~${GERRIT_CHANGE_ID}/revisions/${GERRIT_PATCHSET_REVISION}/commit | python3 -c "import sys, json; sys.stdin.read(4); print(json.load(sys.stdin)['committer']['email'])")
-if [ "${COMMITTER_EMAIL}" = "" ]; then
-    echo "Unable to find committer."
-    "${GERRIT_SSH_CMD[@]}" review \
-        "${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER}" \
-        --ok-to-test=0 "--message='Unable to determine committer'"
-    exit 1
-fi
-
-#echo "Commit by '${COMMITTER_EMAIL}'"
-# shellcheck disable=2086 # GERRIT_COMMAND is purposefully wordsplit.
-COMMITTER_USERNAME=$(${GERRIT_COMMAND}/a/accounts/${COMMITTER_EMAIL} | python3 -c "import sys, json; sys.stdin.read(4); print(json.load(sys.stdin)['username'])")
-#COMMITTER_USERNAME=`${GERRIT_COMMAND}/a/accounts/${COMMITTER_EMAIL}`
+COMMITTER_USERNAME=$("${GERRIT_SSH_CMD[@]}" query "${GERRIT_CHANGE_NUMBER}" --format json | jq -r '.owner.username | select (. != null )')
 echo "USERNAME: $COMMITTER_USERNAME"
 if [ "${COMMITTER_USERNAME}" = "" ]; then
     echo "Unable to determine github user for ${COMMITTER_EMAIL}."