tf-a-lts-verified-propagater: Add some comments

To explain how the job works

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: Ie77a6108964209aefd0993713414ed78992bcaac
diff --git a/tf-a-lts-verified-propagater.yaml b/tf-a-lts-verified-propagater.yaml
index 24c3e3d..5ffe0fb 100644
--- a/tf-a-lts-verified-propagater.yaml
+++ b/tf-a-lts-verified-propagater.yaml
@@ -10,6 +10,13 @@
     builders:
     - shell: |-
         #!/bin/bash
+        # This job is triggered by the label Verified +1 or -1 of the patch
+        # it will vote the same score (Verified +1 / Verified -1) to the dependent patch
+        # , if there is any.
+        # For example, P5 -> P4 -> P3 -> P2 -> P1. P5 dependents on P4, and so on
+        # When P5 gets Verified +1, this job will be triggered and set Verified +1 to P4.
+        # P4 gets Verified +1 triggers an other job to set Verified +1 to P3, and so on.
+        # That is how we propagate the Verified score to the entire patch stack
         set -ex
 
         echo "########################################################################"
@@ -21,25 +28,34 @@
         GERRIT_URL="review.trustedfirmware.org"
         GERRIT_QUERY_PARAMS="--dependencies --submit-records --format=JSON change:"
         QUERY_DEPENDS_CMD="${SSH_PARAMS} ${CI_BOT_USERNAME}@${GERRIT_URL} gerrit query ${GERRIT_QUERY_PARAMS}${GERRIT_CHANGE_NUMBER}"
+        REVIEW_MESSAGE="Propagated verified from ${GERRIT_CHANGE_URL}. By ${BUILD_URL}"
         SET_VERIFIED_CMD="${SSH_PARAMS} ${CI_BOT_USERNAME}@${GERRIT_URL} gerrit review --verified"
 
         change_url_base=${GERRIT_CHANGE_URL%/*}
+        # Check this example https://ci.trustedfirmware.org/view/TF-A/job/tf-a-lts-verified-propagater/14/console
+        # for what we get from gerrit query command
         patch_query=$(ssh ${QUERY_DEPENDS_CMD} | jq .)
         dependsOn=$(echo ${patch_query} | jq -r 'select(.dependsOn)')
+        # Normally, there would be just one dependent patch
+        # (and that patch would in turn has another dependent patch, that's how a dependency chain is structured)
+        # But Gerrit data model has a list of dependent patches, so we process all just in case
         dependsOn_rev=($(echo ${dependsOn} | jq -r '.dependsOn[].revision'))
         dependsOn_no=($(echo ${dependsOn} | jq -r '.dependsOn[].number'))
         verified_status=$(echo ${patch_query} | jq -r 'select(.submitRecords) | .submitRecords[0].labels[] | select(.label == "Verified") | .status')
+        # Verified label status and value mapping
+        # REJECT: -1
+        # OK: 1
         verified_value=0
         if [ "${verified_status}" == "REJECT" ]; then
             verified_value=-1
         elif [ "${verified_status}" == "OK" ]; then
             verified_value=1
         fi
-
+        # Vote the same Verified score to the dependent patch by loop
         for ((i=0; i<${#dependsOn_rev[@]}; i++))
         do
             echo "Set Verified ${verified_value} to: ${change_url_base}/${dependsOn_no[$i]}"
-            ssh ${SET_VERIFIED_CMD} ${verified_value} ${dependsOn_rev[$i]}
+            ssh ${SET_VERIFIED_CMD} ${verified_value}  -m \'\"${REVIEW_MESSAGE}\"\' ${dependsOn_rev[$i]}
         done
     properties:
     - build-discarder: