post_gerrit_comment.sh: Add a helper to limit size of Gerrit comment
Trim the comment to be posted to be under 16K, which appears to be
Gerrit's limit (violating it causes error and build failure).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: I645b84b5e6d931004f526a3463044af77151e7b5
(cherry picked from commit cf3f73c97f69c7454f155c42f00dd06de255d46d)
diff --git a/eclair/post_gerrit_comment.sh b/eclair/post_gerrit_comment.sh
index 70abb01..d0c042b 100755
--- a/eclair/post_gerrit_comment.sh
+++ b/eclair/post_gerrit_comment.sh
@@ -9,6 +9,9 @@
# Set to 0 to temporarily disable posting comments to Gerrit.
should_post_comment=1
+# Directory where this script resides.
+SCRIPT_DIR="$(cd "$(dirname "$0")" ; echo "${PWD}")"
+
# Don't post comments if run on the staging server.
if echo "$JENKINS_URL" | grep -q "ci\.staging"; then
should_post_comment=0
@@ -24,7 +27,7 @@
mkdir -p ~/.ssh/
ssh-keyscan -H -p 29418 $GERRIT_HOST >> ~/.ssh/known_hosts
- quoted="$(python3 -c 'import sys, shlex; print(shlex.quote(open(sys.argv[1]).read()))' misra_delta.txt)"
+ quoted="$(python3 $SCRIPT_DIR/prepare_gerrit_comment.py misra_delta.txt)"
ssh -o "PubkeyAcceptedKeyTypes +ssh-rsa" -p 29418 -i "$CI_BOT_KEY" "$CI_BOT_USERNAME@$GERRIT_HOST" gerrit \
review "$GERRIT_CHANGE_NUMBER,$GERRIT_PATCHSET_NUMBER" \