A failed `pmaint sync` or `pmaint regen` left empty report files, and the comment counted zero new findings and posted good. The scan now leaves a complete marker and the comment reports a scan that did not finish. New findings were keyed by package, keyword and version, so a second finding of the same keyword in an existing version was taken for the old one. They are now compared by their message without line numbers, counted as a multiset. The marker lookup only takes comments written by a bot, so a user comment that quotes the marker is not edited. Signed-off-by: Zakk <zakk@gentoozh.org>
20 lines
661 B
Bash
Executable File
20 lines
661 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# usage: upsert-comment.sh <repository> <issue> <marker> <body-file>
|
|
set -euo pipefail
|
|
|
|
repository=${1:?repository}
|
|
issue=${2:?issue}
|
|
marker=${3:?marker}
|
|
body_file=${4:?body-file}
|
|
|
|
comments=$(gh api "repos/$repository/issues/$issue/comments" --paginate --slurp)
|
|
comment_id=$(jq -r --arg marker "$marker" '
|
|
[.[][] | select(.user.type == "Bot" and (.body | contains($marker)))][0].id // empty
|
|
' <<< "$comments")
|
|
|
|
if [ -n "$comment_id" ]; then
|
|
gh api -X PATCH "repos/$repository/issues/comments/$comment_id" -F "body=@$body_file" >/dev/null
|
|
else
|
|
gh api "repos/$repository/issues/$issue/comments" -F "body=@$body_file" >/dev/null
|
|
fi
|