| #!/bin/bash |
| # ----------------------------------------------------------------------- |
| # Copyright 2024 Open Networking Foundation Contributors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http:#www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # ----------------------------------------------------------------------- |
| # SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors |
| # SPDX-License-Identifier: Apache-2.0 |
| # ----------------------------------------------------------------------- |
| |
| ## ----------------------------------------------------------------------- |
| ## Usage: $0 --status open --reviewer [u] |
| ## ----------------------------------------------------------------------- |
| ## [TODO] |
| ## o Merge into filters/reviewer.sh |
| ## o --reviewer should act as a simple search filter to augment behavior |
| ## o Piece missing is url=$stem when --review is the only command line opt |
| ## ----------------------------------------------------------------------- |
| function do_gerrit_review() |
| { |
| declare -g argv_reviewer |
| |
| # shellcheck disable=SC2178 |
| local -n ref_urls=$1 ; shift |
| local -n ref_repos=$1 ; shift |
| local -n ref_status=$1 ; shift |
| |
| ref_urls=() |
| |
| # local stem='https://gerrit.opencord.org/q/project:voltha-go+status:open' |
| local stem='https://gerrit.opencord.org/q/' |
| |
| local -a common=() |
| if [[ -v me ]]; then |
| common+=('reviewer:self') |
| elif [[ ! argv_reviewer ]] || [[ ${#argv_reviewer[@]} -eq 0 ]]; then |
| common+=('reviewer:self') |
| fi |
| |
| local reviewer |
| for reviewer in "${argv_reviewer[@]}"; do |
| common+=("reviewer:${reviewer}") |
| done |
| |
| local repo |
| for repo in "${ref_repos[@]}"; |
| do |
| local -a args=() |
| args+=("project:${repo}") |
| args+=("${common[@]}") |
| |
| local url="$stem" |
| url+="$(join_by '+' "${args[@]}")" |
| ref_urls+=("$url") |
| done |
| |
| ## If not repo specific then query all |
| if [[ ${#ref_urls[@]} -eq 0 ]]; then |
| local -a args=() |
| args=("${common[@]}") |
| |
| local url="$stem" |
| url+="$(join_by '+' "${args[@]}")" |
| ref_urls+=("$url") |
| fi |
| |
| return |
| } |
| |
| : # ($?==0) for source script |
| |
| # [EOF] |