blob: d8376a7ae9616c008ed63ea80084f429479e87aa [file] [log] [blame]
#!/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 age
## -----------------------------------------------------------------------
function add_filter_age()
{
local val="$1"; shift
case "$val" in
*y|*year*) ;; # 1 y[ear(s)]
*m|*mon*) ;; # 1 m[onth(s)]
*d|*day*) ;; # 1 d[ay(s)]
*h|*hour*) ;; # 1 h[our(s)]
*) error "--age [$val] is invalid" ;;
esac
[[ -v argv_age ]] && { error '--age: detected multiple switches'; }
declare -g -a argv_age=("$age")
return
}
## -----------------------------------------------------------------------
## Intent: Update gerrit query to filter based on created after date
## FMT: 2006-01-02[ 15:04:05[.890][ -0700]];
## -----------------------------------------------------------------------
function add_filter_after()
{
local val="$1"; shift
[[ -v argv_after ]] && { error '--after: detected multiple switches'; }
declare -g -a argv_after=("$arg")
return
}
## -----------------------------------------------------------------------
## Intent: Update gerrit query to filter based on created before date
## FMT: 2006-01-02[ 15:04:05[.890][ -0700]];
## -----------------------------------------------------------------------
function add_filter_before()
{
local val="$1"; shift
[[ -v argv_before ]] && { error '--before: detected multiple switches'; }
declare -g -a argv_before=("$arg")
return
}
## -----------------------------------------------------------------------
## Intent: Merge status attributes into a URL query
## -----------------------------------------------------------------------
function apply_filter_age()
{
local -n ref=$1; shift
[[ -v argv_age ]] && { ref+=("age:\"${argv_age[@]}\""); }
[[ -v argv_after ]] && { ref+=("after:\"${argv_after}\""); }
[[ -v argv_before ]] && { ref+=("before:\"${argv_before}\""); }
:
return
}
: # ($?==0) for source script
# [EOF]