| #!/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 |
| # ----------------------------------------------------------------------- |
| |
| ## ----------------------------------------------------------------------- |
| ## Intent: Update gerrit query to filter based on reviewer |
| ## ----------------------------------------------------------------------- |
| function add_filter_reviewer() |
| { |
| local val="$1"; shift |
| |
| [[ ! -v argv_reviewer ]] && { declare -g -a argv_reviewer=(); } |
| argv_reviewer+=("$val") |
| |
| return |
| } # add_reviewer_filter() |
| |
| ## ----------------------------------------------------------------------- |
| ## Intent: Merge reviewer attributes into a URL query |
| ## ----------------------------------------------------------------------- |
| function apply_filter_reviewer() |
| { |
| local -n ref=$1; shift |
| |
| [[ ! -v argv_reviewer ]] && { return; } |
| |
| echo "REF=[${ref[@]}]" |
| |
| local reviewer |
| for reviewer in "${argv_reviewer[@]}"; |
| do |
| if [[ "${ref[-1]: -1:1}" != '/' ]]; then |
| ref[-1]+='+' # "+reviewer:${reviewer}" |
| fi |
| |
| # https://gerrit.opencord.org/q/reviewer:open |
| # TODO: Do not apply + when |
| # ref[-1]+="+reviewer:${reviewer}" |
| ref[-1]+="reviewer:${reviewer}" |
| done |
| |
| return |
| } |
| |
| : # ($?==0) for source script |
| |
| # [EOF] |