diff --git a/scripts/list_open_MRs.sh b/scripts/list_open_MRs.sh new file mode 100755 index 0000000000000000000000000000000000000000..6b0ca6212cfb861137a4f67cdd56eea2f36c571e --- /dev/null +++ b/scripts/list_open_MRs.sh @@ -0,0 +1,121 @@ +#!/bin/bash + +# +# (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, +# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., +# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, +# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other +# contributors to this repository. All Rights Reserved. +# +# This software is protected by copyright law and by international treaties. +# The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, +# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., +# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, +# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other +# contributors to this repository retain full ownership rights in their respective contributions in +# the software. This notice grants no license of any kind, including but not limited to patent +# license, nor is any license granted by implication, estoppel or otherwise. +# +# Contributors are required to enter into the IVAS codec Public Collaboration agreement before making +# contributions. +# +# This software is provided "AS IS", without any express or implied warranties. The software is in the +# development stage. It is intended exclusively for experts who have experience with such software and +# solely for the purpose of inspection. All implied warranties of non-infringement, merchantability +# and fitness for a particular purpose are hereby disclaimed and excluded. +# +# Any dispute, controversy or claim arising under or in relation to providing this software shall be +# submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in +# accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and +# the United Nations Convention on Contracts on the International Sales of Goods. +# + +# script to list open MRs from the IVAS Gitlab repos +# Markus Multrus, Fraunhofer IIS + +function usage { + echo + echo "Usage:" + echo " $(basename $0) [OPTIONS]" + echo + echo " -r {float,BASOP}: Float (default) or BASOP Repo" + echo " -s {ready,draft,all}: MRs marked as ready (default), draft or all" + exit +} + + +GITLAB_URL="https://forge.3gpp.org/rep/api/v4/" # GitLab API URL +PROJECT_ID_FLOAT="49" # Project ID for "ivas-codec" repo +PROJECT_ID_BASOP="77" # Project ID for "ivas-basop" repo +PER_PAGE=100 # max. number of entries per page; 100 is max. number as supported by Gitlab API + +STATUS_STRING="" +REPO_STRING="" + +while getopts "r:s:h" OPTIONS; do + case ${OPTIONS} in + r) + REPO_STRING=${OPTARG} + ;; + s) + STATUS_STRING=${OPTARG} + ;; + h | *) + usage + ;; + esac +done +shift $((OPTIND - 1)) + +# check, whether we should use float or BASOP +PROJECT_ID=$PROJECT_ID_FLOAT +if [ -n "$REPO_STRING" ]; then + if [ "${REPO_STRING,,}" = "basop" ]; then # ,, => transorm to lower case + PROJECT_ID=$PROJECT_ID_BASOP + elif [ "${REPO_STRING,,}" = "float" ]; then # ,, => transorm to lower case + PROJECT_ID=$PROJECT_ID_FLOAT + else + echo "Invalid repository string given; defaulting to float (ivas-codec)" + fi +fi + +# check, which MR status we should list +CURL_STR="$GITLAB_URL/projects/$PROJECT_ID/merge_requests?state=opened&wip=no&target_branch=main&per_page=$PER_PAGE" +if [ -n "$STATUS_STRING" ]; then + if [ "${STATUS_STRING,,}" = "ready" ]; then # ,, => transorm to lower case + CURL_STR="$GITLAB_URL/projects/$PROJECT_ID/merge_requests?state=opened&wip=no&target_branch=main&per_page=$PER_PAGE" + elif [ "${STATUS_STRING,,}" = "draft" ]; then # ,, => transorm to lower case + CURL_STR="$GITLAB_URL/projects/$PROJECT_ID/merge_requests?state=opened&wip=yes&target_branch=main&per_page=$PER_PAGE" + elif [ "${STATUS_STRING,,}" = "all" ]; then # ,, => transorm to lower case + CURL_STR="$GITLAB_URL/projects/$PROJECT_ID/merge_requests?state=opened&target_branch=main&per_page=$PER_PAGE" + else + echo "Invalid MR status string given; defaulting to ready" + fi +fi + + +# Iterate page-wise over all merge requests +PAGE=1 +RESULTS="[]" + +while :; do + RESPONSE=$(curl --silent "${CURL_STR}&page=$PAGE") + + # check length of response + LENGTH=$(echo "$RESPONSE" | jq '. | length') + echo $LENGTH + + # break if no results are returned + if [ "$LENGTH" -eq 0 ]; then + break + fi + + # add current response/page to list of results + RESULTS=$(echo "$RESULTS" "$RESPONSE" | jq -s 'add') + + # next page + PAGE=$((PAGE + 1)) +done + +echo "$RESULTS" | jq -r '.[] | "\(.web_url) - \(.title)"' +