Skip to content

Commit 69a8052

Browse files
committed
Ignore private changes and comments
Do not process events from changes which are either private or belong to branches where anonymous user doesn't have access (e.g. refs/meta/config branches). If it's not readable by anonymous user - don't run it. Signed-off-by: Karol Latecki <[email protected]>
1 parent 0d5c80a commit 69a8052

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.github/scripts/parse_false_positive_comment.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spdk_repo=$REPO
1717
gerrit_comment=$COMMENT
1818
reported_by=$AUTHOR
1919

20-
gerrit_url=https://review.spdk.io/a/changes
20+
gerrit_url=https://review.spdk.io/changes
2121
gerrit_format_q="o=DETAILED_ACCOUNTS&o=MESSAGES&o=LABELS&o=SKIP_DIFFSTAT"
2222

2323
# Looking for comment thats only content is "false positive: 123", with a leeway for no spaces
@@ -48,6 +48,12 @@ curl -s -X GET \
4848
"$gerrit_url/spdk%2Fspdk~$change_num?$gerrit_format_q" \
4949
| tail -n +2 | jq . | tee change.json
5050

51+
if [[ ! -s change.json ]]; then
52+
echo "Change $change_num not found, exiting."
53+
echo "Either it's a private change or in restricted branch."
54+
exit 0
55+
fi
56+
5157
# Do not test any change marked as WIP
5258
ready_for_review="$(jq -r '.has_review_started' change.json)"
5359
if [[ "$ready_for_review" == "false" ]]; then

.github/workflows/gerrit-webhook-handler.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ jobs:
4646
set -x
4747
4848
# Get latest info about a change itself
49-
curl -s -X GET "https://review.spdk.io/a/changes/spdk%2Fspdk~${{ env.change_num }}?o=DETAILED_ACCOUNTS&o=LABELS&o=SKIP_DIFFSTAT" \
50-
--user "${{ secrets.GERRIT_BOT_USER }}:${{ secrets.GERRIT_BOT_HTTP_PASSWD }}" \
51-
| tail -n +2 > change.json
49+
curl -s -X GET "https://review.spdk.io/changes/spdk%2Fspdk~${{ env.change_num }}?o=DETAILED_ACCOUNTS&o=LABELS&o=SKIP_DIFFSTAT" \
50+
| tail -n +2 > change.json
51+
52+
if [[ ! -s change.json ]]; then
53+
echo "Change ${{ env.change_num }} not found, exiting."
54+
echo "Either it's a private change or in restricted branch."
55+
gh run cancel ${{ github.run_id }} -R ${{ github.repository }}
56+
fi
5257
5358
# Do not test any change marked as WIP
5459
ready_for_review="$(jq -r '.has_review_started' change.json)"

0 commit comments

Comments
 (0)