Edits to support  --review(er)

Change-Id: I65987a443feda52b0043b55bf2a13446dd93ec14
diff --git a/gerrit/README.md b/gerrit/README.md
index f2cdf6c..d2fc2ed 100644
--- a/gerrit/README.md
+++ b/gerrit/README.md
@@ -20,15 +20,23 @@
 | [x](https://gerrit.opencord.org/q/status:open)  | gerrit.sh --all voltha-lib-go | Display metadata for a repo: branches, tags, source |
 | [x](https://gerrit.opencord.org/q/status:merged) | gerrit.sh --status merged [--user u] | View merged patches |
 
-My patches and pending reviews
-------------------------------
+Search for unmerged patches
+-------------------
 
 | Jira | Command | Description |
 | ---- | ------- | ----------- |
 | [x](https://gerrit.opencord.org/q/owner:joey@opennetworking.org+status:open) | gerrit.sh --wip --me | Display my unmerged patches |
 
-Gerrit by repository
---------------------
+Pending code reviews
+-----------------------
+
+| Jira | Command | Description |
+| ---- | ------- | ----------- |
+| [x](https://gerrit.opencord.org/q/reviewer:self) | gerrit.sh --review --my | Display my pending code reviews |
+| [x](https://gerrit.opencord.org/q/reviewer:self) | gerrit.sh --reviewer [u] --reviewer [u]| Display pending code reviews by user |
+
+By repository
+-------------
 
 | Jira | Command | Description |
 | ---- | ------- | ----------- |
diff --git a/gerrit/bin/gerrit.sh b/gerrit/bin/gerrit.sh
index 3463960..572d1d3 100755
--- a/gerrit/bin/gerrit.sh
+++ b/gerrit/bin/gerrit.sh
@@ -28,6 +28,7 @@
 ##---]  INCLUDES  [---##
 ##--------------------##
 source "${libdir}/filters/include.sh"
+source "${libdir}/do/include.sh"
 source "${libdir}/usage/include.sh"
 
 ## --------------------------------------------------------------------
@@ -41,7 +42,7 @@
 ** ERROR: $@
 ** -----------------------------------------------------------------------
 ERROR
-    echo 
+    echo
     exit 1
 }
 
@@ -56,7 +57,7 @@
 ## -----------------------------------------------------------------------
 ## Usage: $0 --repo voltha-go --search --wip
 ## -----------------------------------------------------------------------
-function do_gerrit_search()
+function do_gerrit_search_orig()
 {
     local -n ref_urls=$1   ; shift
     local -n ref_repos=$1   ; shift
@@ -92,7 +93,7 @@
         ref_urls+=("$url")
     fi
 
-	# --debug)  declare -g -i debug=1 ;;
+    # --debug)  declare -g -i debug=1 ;;
     # --search) declare -g -i search=1 ;;
     # --wip)    declare -g -i status_is_open=1 ;;
 
@@ -100,56 +101,6 @@
 }
 
 ## -----------------------------------------------------------------------
-## Usage: $0 --status open --reviewer [u]
-## -----------------------------------------------------------------------
-function do_gerrit_review()
-{
-    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=()
-    [[ -v me ]] && { common+=('reviewer:self') }
-
-    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
-
-	# --debug)  declare -g -i debug=1 ;;
-    # --search) declare -g -i search=1 ;;
-    # --wip)    declare -g -i status_is_open=1 ;;
-
-    return
-}
- 
-## -----------------------------------------------------------------------
 ## Intent: Iterate over --admin values and generate repositories
 ## -----------------------------------------------------------------------
 function gen_admin_urls()
@@ -185,6 +136,7 @@
 ## -----------------------------------------------------------------------
 function gen_view_urls()
 {
+    # shellcheck disable=SC2178
     local -n ref=$1    ; shift
     local -n _repos=$1 ; shift
     local -n _views=$1 ; shift
@@ -207,22 +159,22 @@
                 search) continue ;;
                 default) ref+=("$stem")                      ;;
                 # repo*) ref+=("$stem/$repo")                ;;
-                  repo*) ref+=("$stem")                      ;;
-                  master)
-                      ref+=("$stem/+/refs/heads/master")
-                      ;;
-
-                  voltha-*)
-                      echo "STEM: $stem"
-                      if false; then
-                          ref+=("$stem/+/refs/tags/${view}")
-                          ref+=("$stem/+/refs/heads/${view}")
-                      fi
-                      # ref+=("$stem/+/refs/heads/${view}")
-                      ref+=("$stem/+/refs/heads/${view}")
+                repo*) ref+=("$stem")                      ;;
+                master)
+                    ref+=("$stem/+/refs/heads/master")
                     ;;
 
-                    v*)  ref+=("$stem/+/refs/tags/${view}")  ;;
+                voltha-*)
+                    echo "STEM: $stem"
+                    if false; then
+                        ref+=("$stem/+/refs/tags/${view}")
+                        ref+=("$stem/+/refs/heads/${view}")
+                    fi
+                    # ref+=("$stem/+/refs/heads/${view}")
+                    ref+=("$stem/+/refs/heads/${view}")
+                    ;;
+
+                v*)  ref+=("$stem/+/refs/tags/${view}")  ;;
                 *) error "Unknown --view type [$view]"       ;;
             esac
         done # views[@]
@@ -240,6 +192,7 @@
 ## -----------------------------------------------------------------------
 function get_urls()
 {
+    # shellcheck disable=SC2178
     local -n ref="$1"; shift
     local _srv="$1"; shift
 
@@ -247,8 +200,8 @@
     ref=(\
          ['admin']="$gerrit/admin/repos"
          ['base']="$gerrit"\
-         ['dashboard']="$gerrit/dashboard/self"\
-    )
+                 ['dashboard']="$gerrit/dashboard/self"\
+             )
     return
 }
 
@@ -258,6 +211,7 @@
 {
     local _repo="$1"; shift
     local _id="$1";   shift
+    # shellcheck disable=SC2178
     local -n ref=$1;  shift
 
     local url="https://gerrit.opencord.org/c/${repo}/+/${id}"
@@ -278,6 +232,7 @@
 ## -----------------------------------------------------------------------
 function access_url()
 {
+    # shellcheck disable=SC2178
     local -n ref=$1; shift
     local _repo="$1"; shift
 
@@ -307,6 +262,7 @@
 ## -----------------------------------------------------------------------
 function do_gerrit_dashboard()
 {
+    # shellcheck disable=SC2178
     local -n ref=$1; shift
 
     declare -A data=()
@@ -338,13 +294,15 @@
             ;;
 
         ## Modes
-	    --debug)
+        --debug)
+            # shellcheck disable=SC2034
             declare -g -i argv_debug=1
             declare -g -i debug=1
             ;;
         --search) declare -g -i argv_search=1 ;;
 
         --me)
+            # shellcheck disable=SC2034
             declare -g -i argv_me=1
             me+=("owner:${USER}@opennetworking.org")
             ;;
@@ -384,7 +342,7 @@
                 versions+=('master')
             fi
 
-#            args+=('--view'  'voltha-2.11')
+            #            args+=('--view'  'voltha-2.11')
             args+=('--view'  'voltha-2.12')
             set -- "${args[@]}" "$@"
             ;;
@@ -469,6 +427,7 @@
             ;;
 
         --reviewer)
+            [[ $# -eq 0 ]] && { error '--reviewer requires an argument'; }
             arg="$1"; shift
             add_filter_reviewer "$arg"
 
@@ -511,12 +470,12 @@
             esac
             ;;
 
-	    -*)
-	        echo "ERROR: Unknown argument [$arg]"
-	        exit 1
-	        ;;
+        -*)
+            echo "ERROR: Unknown argument [$arg]"
+            exit 1
+            ;;
 
-	    [[:alnum:]]*)
+        [[:alnum:]]*)
             declare -a what=()
             # whats+=('patches')
             whats+=('versions')
@@ -539,25 +498,19 @@
     esac
 done
 
-[[ -v argv_search ]]   && { do_gerrit_search urls repos argv_status; }
+[[ -v argv_search ]] && { do_gerrit_search urls repos argv_status; }
 [[ -v admins ]]      && { gen_admin_urls urls repos admins; }
-
-# -----------------------------------------------------------------------
-# Generalize:
-#   o --review function like a simple search filter.
-#   o piece missing is defining query URL stem= when needed.
-# -----------------------------------------------------------------------
 [[ -v argv_review ]] && { do_gerrit_review urls repos argv_status; }
 
 ## are --views working ?
 [[ "${#views[@]}" -gt 0 ]] && { gen_view_urls  urls repos views;  }
 
 if [[ ${#urls[@]} -eq 0 ]]; then
+    # shellcheck disable=SC2034
     declare -a show_all=() # show all for visiblity
     do_gerrit_search urls repos show_all
 fi
 
-
 [[ -v debug ]] && { echo "$BROWSER" "${urls[@]}"; }
 
 if [[ ${#urls[@]} -gt 0 ]]; then
@@ -588,5 +541,4 @@
 #            argv_status+=('status:open')
 #            ;;
 
-
 # [EOF]
diff --git a/gerrit/gerrit/do/admin.sh b/gerrit/gerrit/do/admin.sh
new file mode 100644
index 0000000..0e51e00
--- /dev/null
+++ b/gerrit/gerrit/do/admin.sh
@@ -0,0 +1,24 @@
+#!/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
+# -----------------------------------------------------------------------
+
+
+: # ($?==0) for source script
+
+# [EOF]
diff --git a/gerrit/gerrit/do/include.sh b/gerrit/gerrit/do/include.sh
new file mode 100644
index 0000000..f510955
--- /dev/null
+++ b/gerrit/gerrit/do/include.sh
@@ -0,0 +1,29 @@
+#!/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
+# -----------------------------------------------------------------------
+
+##--------------------##
+##---]  INCLUDES  [---##
+##--------------------##
+source "${libdir}/do/reviewer.sh"
+source "${libdir}/do/search.sh"
+
+: # ($?==0) for source script
+
+# [EOF]
diff --git a/gerrit/gerrit/do/reviewer.sh b/gerrit/gerrit/do/reviewer.sh
new file mode 100644
index 0000000..32aaeae
--- /dev/null
+++ b/gerrit/gerrit/do/reviewer.sh
@@ -0,0 +1,82 @@
+#!/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]
diff --git a/gerrit/gerrit/do/search.sh b/gerrit/gerrit/do/search.sh
new file mode 100644
index 0000000..d2fbf28
--- /dev/null
+++ b/gerrit/gerrit/do/search.sh
@@ -0,0 +1,69 @@
+#!/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 --repo voltha-go --search --wip
+## -----------------------------------------------------------------------
+function do_gerrit_search()
+{
+    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=()
+    [[ -v me ]] && { common+=("${me[@]}"); }
+    common+=("${ref_status[@]}")
+
+    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 [[ ${#ref_urls[@]} -eq 0 ]]; then
+        local -a args=()
+        args=("${common[@]}")
+
+        local url="$stem"
+        url+="$(join_by '+' "${args[@]}")"
+        ref_urls+=("$url")
+    fi
+
+	# --debug)  declare -g -i debug=1 ;;
+    # --search) declare -g -i search=1 ;;
+    # --wip)    declare -g -i status_is_open=1 ;;
+
+    return
+}
+
+: # ($?==0) for source script
+
+# [EOF]