2021-09-10 16:33:13 +03:00
|
|
|
#!/usr/bin/env bash
|
2021-09-14 11:48:02 +03:00
|
|
|
#1: BRANCH
|
|
|
|
#2: TYPE
|
|
|
|
#3: PR
|
2021-09-10 16:33:13 +03:00
|
|
|
|
2024-03-29 18:56:51 +03:00
|
|
|
# SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
# SPDX-FileCopyrightText: 2016 Tobias Kaminsky <tobias@kaminsky.me>
|
2024-03-29 21:22:56 +03:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2024-03-29 18:56:51 +03:00
|
|
|
|
2021-09-10 16:33:13 +03:00
|
|
|
BRANCH=$1
|
|
|
|
TYPE=$2
|
|
|
|
PR=$3
|
2022-05-31 11:07:03 +03:00
|
|
|
|
|
|
|
source scripts/lib.sh
|
2021-09-10 16:36:29 +03:00
|
|
|
|
2021-09-10 16:33:13 +03:00
|
|
|
BRANCH_TYPE=$BRANCH-$TYPE
|
|
|
|
|
|
|
|
# delete all old comments, matching this type
|
|
|
|
echo "Deleting old comments for $BRANCH_TYPE"
|
2022-05-31 11:07:03 +03:00
|
|
|
oldComments=$(curl_gh -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("(nextcloud-android-bot|github-actions)") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
2021-09-14 11:48:02 +03:00
|
|
|
count=$(echo -n "$oldComments" | grep -c '^')
|
2021-09-10 16:33:13 +03:00
|
|
|
echo "Found $count old comments"
|
|
|
|
|
2021-09-14 11:48:02 +03:00
|
|
|
if [ "$count" -gt 0 ]; then
|
|
|
|
echo "$oldComments" | while read comment ; do
|
|
|
|
echo "Deleting comment: $comment"
|
2022-05-31 11:07:03 +03:00
|
|
|
curl_gh -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
2021-09-14 11:48:02 +03:00
|
|
|
done
|
|
|
|
fi
|
2021-09-10 16:33:13 +03:00
|
|
|
|
|
|
|
exit 0
|