Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ## ----------------------------------------------------------------------- |
| 3 | ## Intent: Construct gerrit server queries and URLs based on arguments |
| 4 | ## ----------------------------------------------------------------------- |
| 5 | |
| 6 | { # loader |
| 7 | declare pgm='' |
| 8 | pgm="$(realpath --canonicalize-existing "$0")" |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 9 | readonly pgm |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 10 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 11 | declare libdir="${pgm%/*}" |
| 12 | libdir="${libdir%/*}/gerrit" |
| 13 | readonly libdir |
| 14 | |
| 15 | declare root='' |
| 16 | root="${pgm%%/gerrit/bin/gerrit.sh}" |
| 17 | source "$root/lf/onf-common/common.sh" '--common-args-begin--' |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | ##-------------------## |
| 21 | ##---] GLOBALS [---## |
| 22 | ##-------------------## |
| 23 | declare -g serv='gerrit.opencord.org' |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 24 | declare -x -g BROWSER="${BROWSER:-/usr/local/bin/firefox}" |
| 25 | declare -g -a me=() |
| 26 | |
| 27 | ##--------------------## |
| 28 | ##---] INCLUDES [---## |
| 29 | ##--------------------## |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 30 | source "${libdir}/filters/include.sh" |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 31 | source "${libdir}/do/include.sh" |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 32 | source "${libdir}/usage/include.sh" |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 33 | |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 34 | ## -------------------------------------------------------------------- |
| 35 | ## -------------------------------------------------------------------- |
| 36 | function error() |
| 37 | { |
| 38 | cat <<ERROR |
| 39 | |
| 40 | ** ----------------------------------------------------------------------- |
| 41 | ** IAM: ${FUNCNAME[1]} |
| 42 | ** ERROR: $@ |
| 43 | ** ----------------------------------------------------------------------- |
| 44 | ERROR |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 45 | echo |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 46 | exit 1 |
| 47 | } |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 48 | |
| 49 | ## ----------------------------------------------------------------------- |
| 50 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 51 | # function join_by_orig() |
| 52 | function join_by() |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 53 | { |
| 54 | local d=${1-} f=${2-}; if shift 2; then printf %s "$f" "${@/#/$d}"; fi; |
| 55 | } |
| 56 | |
| 57 | ## ----------------------------------------------------------------------- |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 58 | ## Intent: Iterate over --admin values and generate repositories |
| 59 | ## ----------------------------------------------------------------------- |
| 60 | function gen_admin_urls() |
| 61 | { |
| 62 | local -n ref=$1 ; shift |
| 63 | local -n _repos=$1 ; shift |
| 64 | local -n _admins=$1 ; shift |
| 65 | |
| 66 | local repo |
| 67 | for repo in "${_repos[@]}"; |
| 68 | do |
| 69 | local attr |
| 70 | for admin in "${_admins[@]}"; |
| 71 | do |
| 72 | # https://gerrit.opencord.org/admin/repos/voltha-go |
| 73 | case "$admin" in |
| 74 | branches) |
| 75 | ref+=("https://gerrit.opencord.org/admin/repos/${repo},branches") |
| 76 | ;; |
| 77 | tags) |
| 78 | ref+=("https://gerrit.opencord.org/admin/repos/${repo},tags") |
| 79 | ;; |
| 80 | *) error "Unknown --admin type [$admin]" ;; |
| 81 | esac |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 82 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 83 | done # admins[@] |
| 84 | done # repos[@] |
| 85 | return |
| 86 | } |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 87 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 88 | ## ----------------------------------------------------------------------- |
| 89 | ## Intent: Iterate over --admin values and generate repositories |
| 90 | ## ----------------------------------------------------------------------- |
| 91 | function gen_view_urls() |
| 92 | { |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 93 | # shellcheck disable=SC2178 |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 94 | local -n ref=$1 ; shift |
| 95 | local -n _repos=$1 ; shift |
| 96 | local -n _views=$1 ; shift |
| 97 | |
| 98 | local -a view_keys=("${!_views[@]}") |
| 99 | local stem0="https://gerrit.opencord.org/plugins/gitiles" |
| 100 | |
| 101 | # https://gerrit.opencord.org/plugins/gitiles/ofagent-go |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 102 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 103 | local repo |
| 104 | for repo in "${_repos[@]}"; |
| 105 | do |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 106 | local stem="${stem0}/$repo" |
| 107 | local view |
| 108 | for view in "${view_keys[@]}"; |
| 109 | do |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 110 | # https://gerrit.opencord.org/admin/repos/voltha-go |
| 111 | case "$view" in |
| 112 | # https://gerrit.opencord.org/plugins/gitiles/voltha-system-tests |
| 113 | search) continue ;; |
| 114 | default) ref+=("$stem") ;; |
| 115 | # repo*) ref+=("$stem/$repo") ;; |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 116 | repo*) ref+=("$stem") ;; |
| 117 | master) |
| 118 | ref+=("$stem/+/refs/heads/master") |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 119 | ;; |
| 120 | |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 121 | voltha-*) |
| 122 | echo "STEM: $stem" |
| 123 | if false; then |
| 124 | ref+=("$stem/+/refs/tags/${view}") |
| 125 | ref+=("$stem/+/refs/heads/${view}") |
| 126 | fi |
| 127 | # ref+=("$stem/+/refs/heads/${view}") |
| 128 | ref+=("$stem/+/refs/heads/${view}") |
| 129 | ;; |
| 130 | |
| 131 | v*) ref+=("$stem/+/refs/tags/${view}") ;; |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 132 | *) error "Unknown --view type [$view]" ;; |
| 133 | esac |
| 134 | done # views[@] |
| 135 | done # repos[@] |
| 136 | |
| 137 | for r in "${ref[@]}"; |
| 138 | do |
| 139 | echo "REPO: $r" |
| 140 | done |
| 141 | |
| 142 | return |
| 143 | } |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 144 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 145 | ## ----------------------------------------------------------------------- |
| 146 | ## ----------------------------------------------------------------------- |
| 147 | function get_urls() |
| 148 | { |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 149 | # shellcheck disable=SC2178 |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 150 | local -n ref="$1"; shift |
| 151 | local _srv="$1"; shift |
| 152 | |
| 153 | local gerrit="https://${_srv}" |
| 154 | ref=(\ |
| 155 | ['admin']="$gerrit/admin/repos" |
| 156 | ['base']="$gerrit"\ |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 157 | ['dashboard']="$gerrit/dashboard/self"\ |
| 158 | ) |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 159 | return |
| 160 | } |
| 161 | |
| 162 | ## ----------------------------------------------------------------------- |
| 163 | ## ----------------------------------------------------------------------- |
| 164 | function changeset() |
| 165 | { |
| 166 | local _repo="$1"; shift |
| 167 | local _id="$1"; shift |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 168 | # shellcheck disable=SC2178 |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 169 | local -n ref=$1; shift |
| 170 | |
| 171 | local url="https://gerrit.opencord.org/c/${repo}/+/${id}" |
| 172 | ref+=("$url") |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | ## ----------------------------------------------------------------------- |
| 177 | ## ----------------------------------------------------------------------- |
| 178 | function browse() |
| 179 | { |
| 180 | local -n _urls=$1; shift |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 181 | "${BROWSER}" "${_urls[@]}" >/dev/null 2>/dev/null & |
| 182 | return |
| 183 | } |
| 184 | |
| 185 | ## ----------------------------------------------------------------------- |
| 186 | ## ----------------------------------------------------------------------- |
| 187 | function access_url() |
| 188 | { |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 189 | # shellcheck disable=SC2178 |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 190 | local -n ref=$1; shift |
| 191 | local _repo="$1"; shift |
| 192 | |
| 193 | declare -A data=() |
| 194 | get_urls data "$serv" |
| 195 | |
| 196 | # declare -p data | tr '=' '\n' |
| 197 | # ref+=("https://gerrit.opencord.org/admin/repos/${_repo},access") |
| 198 | ref+=("${data['admin']}/${_repo},access") |
| 199 | |
| 200 | # browse urls |
| 201 | return |
| 202 | } |
| 203 | |
| 204 | ## ----------------------------------------------------------------------- |
| 205 | ## ----------------------------------------------------------------------- |
| 206 | function branch_url() |
| 207 | { |
| 208 | local _repo="$1"; shift |
| 209 | local -a urls=() |
| 210 | urls+=("https://gerrit.opencord.org/admin/repos/${_repo},branches") |
| 211 | browse urls |
| 212 | return |
| 213 | } |
| 214 | |
| 215 | ## ----------------------------------------------------------------------- |
| 216 | ## ----------------------------------------------------------------------- |
| 217 | function do_gerrit_dashboard() |
| 218 | { |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 219 | # shellcheck disable=SC2178 |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 220 | local -n ref=$1; shift |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 221 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 222 | declare -A data=() |
| 223 | get_urls data "$serv" |
| 224 | ref+=("${data['dashboard']}") |
| 225 | return |
| 226 | } |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 227 | |
| 228 | # https://gerrit.opencord.org/q/status:open+-is:wip |
| 229 | |
| 230 | # repo='' |
| 231 | declare -a urls=() |
| 232 | |
| 233 | ##----------------## |
| 234 | ##---] MAIN [---## |
| 235 | ##----------------## |
| 236 | [[ $# -eq 0 ]] && { set -- '--help'; } |
| 237 | |
| 238 | while [ $# -ne 0 ]; do |
| 239 | arg="$1"; shift |
| 240 | case "$arg" in |
| 241 | --help) usage; exit 0 ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 242 | --help-*) |
| 243 | case "$arg" in |
| 244 | --help-status) usage_verbose "$arg" ;; |
| 245 | *) usage ;; |
| 246 | esac |
| 247 | exit 0 |
| 248 | ;; |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 249 | |
| 250 | ## Modes |
Joey Armstrong | 49d2dce | 2024-04-25 11:22:09 -0400 | [diff] [blame] | 251 | --age) # https://gerrit-review.googlesource.com/Documentation/user-search.html |
| 252 | arg="$1"; shift |
| 253 | add_filter_age "$arg" |
| 254 | ;; |
| 255 | |
| 256 | ## FMT: 2006-01-02[ 15:04:05[.890][ -0700]]; |
| 257 | --after|--since) # https://gerrit-review.googlesource.com/Documentation/user-search.html |
| 258 | arg="$1"; shift |
| 259 | add_filter_after "$arg" |
| 260 | ;; |
| 261 | |
| 262 | ## FMT: 2006-01-02[ 15:04:05[.890][ -0700]]; |
| 263 | --before) # https://gerrit-review.googlesource.com/Documentation/user-search.html |
| 264 | arg="$1"; shift |
| 265 | add_filter_before "$arg" |
| 266 | ;; |
| 267 | |
| 268 | ## Modes |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 269 | --debug) |
| 270 | # shellcheck disable=SC2034 |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 271 | declare -g -i argv_debug=1 |
| 272 | declare -g -i debug=1 |
| 273 | ;; |
Joey Armstrong | 49d2dce | 2024-04-25 11:22:09 -0400 | [diff] [blame] | 274 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 275 | --search) declare -g -i argv_search=1 ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 276 | |
| 277 | --me) |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 278 | # shellcheck disable=SC2034 |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 279 | declare -g -i argv_me=1 |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 280 | me+=("owner:${USER}@opennetworking.org") |
| 281 | ;; |
| 282 | |
| 283 | --todo) source "$root/gerrit/todo.sh" ;; |
| 284 | |
Joey Armstrong | 4e36d66 | 2024-04-16 10:10:04 -0400 | [diff] [blame] | 285 | --unmerged|--wip) |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 286 | declare -a args=() |
| 287 | args=('--status' 'open') |
| 288 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 289 | set -- "${args[@]}" |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 290 | ;; |
| 291 | |
| 292 | --admin) |
| 293 | [[ ! -v admins ]] && { declare -a admins=(); } |
| 294 | arg="$1"; shift |
| 295 | case "$arg" in |
| 296 | br*) admins+=('branches') ;; |
| 297 | ta*) admins+=('tags') ;; |
| 298 | *) error "Unknown --attr value [$attr]" ;; |
| 299 | ## Also master and voltha-2.12 |
| 300 | # https://gerrit.opencord.org/plugins/gitiles/voltha-go/+/refs/heads/voltha-2.12 |
| 301 | esac |
| 302 | ;; |
| 303 | |
| 304 | --all) |
| 305 | repo="$1"; shift |
| 306 | declare -a args=() |
| 307 | args+=('--repo' "$repo") |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 308 | # |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 309 | args+=('--admin' 'branches') |
| 310 | args+=('--admin' 'tags') |
| 311 | |
| 312 | # args+=('--view') # post getopts expansion |
| 313 | # if @versions() else master |
| 314 | if [[ ${#versions[@]} -eq 0 ]]; then |
| 315 | versions+=('master') |
| 316 | fi |
| 317 | |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 318 | # args+=('--view' 'voltha-2.11') |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 319 | args+=('--view' 'voltha-2.12') |
| 320 | set -- "${args[@]}" "$@" |
| 321 | ;; |
| 322 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 323 | --repo) |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 324 | repo="$1"; shift |
| 325 | [[ ! -v repos ]] && { declare -a repos=(); } |
| 326 | repos+=("$repo") |
| 327 | ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 328 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 329 | --serv) serv="$1"; shift |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 330 | case "$serv" in |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 331 | *cord*) serv='gerrit.opencord.org' ;; |
| 332 | *onos*) serv='gerrit.onosproject.org' ;; |
| 333 | *) error "Detected invalid --serv $serv" ;; |
| 334 | esac |
| 335 | ;; |
| 336 | |
| 337 | --access) |
| 338 | [[ ! -v repo ]] && { error "--repo is required"; } |
| 339 | access_url urls "$repo" |
| 340 | ;; |
| 341 | |
| 342 | --branch) |
| 343 | [[ ! -v repo ]] && { error "--repo is required"; } |
| 344 | branch_url "$repo" |
| 345 | ;; |
| 346 | |
| 347 | --crowd*) |
| 348 | # https://crowd.opennetworking.org/crowd/console/secure/group/browse.action?directoryId=163841&updateSuccessful= |
| 349 | declare https='https://crowd.opennetworking.org' |
| 350 | declare base_url="${https}/crowd/console/secure/group/browse.action" |
| 351 | case "$arg" in |
| 352 | --crowd-*) |
| 353 | # urls+=("${base_url}?directoryId=163841&updateSuccessful=") |
| 354 | urls+=("${base_url}") |
| 355 | ;; |
| 356 | *) |
| 357 | # https://crowd.opennetworking.org/crowd/console/secure/group/browse.action?search=%22VOLTHACore%22 |
| 358 | [[ $# -eq 0 ]] && { error "--crowd requires an argument"; } |
| 359 | arg="$1"; shift |
| 360 | urls+=("${base_url}?search=%22${arg}%22") |
| 361 | ;; |
| 362 | esac |
| 363 | ;; |
| 364 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 365 | --*desk) error "Try --dashboard instead" ;; |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 366 | --dash*) do_gerrit_dashboard urls ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 367 | |
| 368 | # |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 369 | --group*) |
| 370 | case "$arg" in |
| 371 | --group*) |
| 372 | urls+=("https://${serv}/admin/groups") |
| 373 | ;; |
| 374 | *) |
| 375 | [[ $# -eq 0 ]] && { error "--group requires an argument"; } |
| 376 | arg="$1"; shift |
| 377 | urls+=("https://${serv}/admin/groups/q/filter:${arg}}") |
| 378 | ;; |
| 379 | esac |
| 380 | ;; |
| 381 | |
| 382 | --id) |
| 383 | id="$1"; shift |
| 384 | [[ ${#repo} -eq 0 ]] && { error "--repo is required"; } |
| 385 | changeset "$repo" "$id" urls |
| 386 | ;; |
| 387 | |
| 388 | --status) |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 389 | arg="$1"; shift # open, closed, merged |
| 390 | case "$arg" in |
| 391 | closed|open|merged) add_filter_status "$arg";; |
| 392 | *) error "Detected invalid --status [$arg]" ;; |
| 393 | esac |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 394 | ;; |
| 395 | |
| 396 | --patch*) |
| 397 | repo="$1"; shift |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 398 | urls+=("https://gerrit.opencord.org/q/${repo}+status:open") |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 399 | # https://gerrit.opencord.org/q/voltha-openolt-adapter-go |
| 400 | ;; |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 401 | |
| 402 | --reviewer) |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 403 | [[ $# -eq 0 ]] && { error '--reviewer requires an argument'; } |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 404 | arg="$1"; shift |
| 405 | add_filter_reviewer "$arg" |
| 406 | |
| 407 | declare -g -i argv_review=1 |
| 408 | # Replace with: set -- '--review' "$@" |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 409 | ;; |
| 410 | |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 411 | --review) declare -g -i argv_review=1 ;; |
| 412 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 413 | --ver*) |
| 414 | [[ $# -eq 0 ]] && { error "Usage: $arg [str]"; } |
| 415 | arg="$1"; shift |
| 416 | [[ ! -v versions ]] && { declare -a versions=(); } |
| 417 | versions+=("$arg") |
| 418 | ;; |
| 419 | |
| 420 | # post getopt expansion to support --version x --version y |
| 421 | --view) |
| 422 | [[ $# -eq 0 ]] && { set -- '--default'; } |
| 423 | arg="$1"; shift |
| 424 | # [[ "${#views[@]}" -gt 0 ]] |
| 425 | [[ ! -v views ]] && { declare -A views=(); } |
| 426 | case "$arg" in |
| 427 | |
| 428 | search*) |
| 429 | urls+=('https://gerrit.opencord.org/admin/repos') |
| 430 | ;; |
| 431 | |
| 432 | repo) views['repository']=1 ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 433 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 434 | # https://gerrit.opencord.org/plugins/gitiles/voltha-go |
| 435 | master) views['master']=1 ;; |
| 436 | voltha*) views["$arg"]=1 ;; |
| 437 | v*) views["$arg"]=1 ;; |
| 438 | *) |
| 439 | # Missing latest tags |
| 440 | views['default']=1 |
| 441 | views['master']=1 |
| 442 | ;; |
| 443 | esac |
| 444 | ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 445 | |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 446 | -*) |
| 447 | echo "ERROR: Unknown argument [$arg]" |
| 448 | exit 1 |
| 449 | ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 450 | |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 451 | [[:alnum:]]*) |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 452 | declare -a what=() |
| 453 | # whats+=('patches') |
| 454 | whats+=('versions') |
| 455 | |
| 456 | stem="https://gerrit.opencord.org/q/${arg}" |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 457 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 458 | for what in "${whats[@]}"; |
| 459 | do |
| 460 | case "$what" in |
| 461 | patches) urls+=("https://gerrit.opencord.org/q/${arg}") ;; |
| 462 | versions) |
| 463 | urls+=("https://gerrit.opencord.org/plugins/gitiles/${arg}/+/refs/heads/master/VERSION") |
| 464 | # urls+=("https://gerrit.opencord.org/plugins/gitiles/${arg}/+/refs/tags/v0.3.6/VERSION") |
| 465 | urls+=("https://gerrit.opencord.org/plugins/gitiles/${arg}/+/refs/heads/voltha-2.12/VERSION") |
| 466 | ;; |
| 467 | '??') urls+=("https://gerrit.opencord.org/plugins/gitiles/${arg}") ;; |
| 468 | *) urls+=("https://gerrit.opencord.org/q/${arg}") ;; |
| 469 | esac |
| 470 | done |
| 471 | esac |
| 472 | done |
| 473 | |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 474 | [[ -v argv_search ]] && { do_gerrit_search urls repos argv_status; } |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 475 | [[ -v admins ]] && { gen_admin_urls urls repos admins; } |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 476 | [[ -v argv_review ]] && { do_gerrit_review urls repos argv_status; } |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 477 | |
| 478 | ## are --views working ? |
| 479 | [[ "${#views[@]}" -gt 0 ]] && { gen_view_urls urls repos views; } |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 480 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 481 | if [[ ${#urls[@]} -eq 0 ]]; then |
Joey Armstrong | d5e1b63 | 2024-03-25 12:18:00 -0400 | [diff] [blame] | 482 | # shellcheck disable=SC2034 |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 483 | declare -a show_all=() # show all for visiblity |
| 484 | do_gerrit_search urls repos show_all |
| 485 | fi |
| 486 | |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 487 | [[ -v debug ]] && { echo "$BROWSER" "${urls[@]}"; } |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 488 | |
| 489 | if [[ ${#urls[@]} -gt 0 ]]; then |
| 490 | apply_filter_status urls |
| 491 | browse urls |
| 492 | fi |
Joey Armstrong | dc364a1 | 2024-02-29 15:14:11 -0500 | [diff] [blame] | 493 | |
| 494 | ## ----------------------------------------------------------------------- |
| 495 | ## [TODO] |
| 496 | ## Query patches by repo:voltha-lib-go |
| 497 | ## ssh gerrit.opencord.org gerrit query --patch-sets projects:voltha-lib-go | grep -i description |
| 498 | # ssh gerrit.opencord.org gerrit query --patch-sets 'projects:voltha-lib-go AND status:open limit:2' | |
| 499 | |
| 500 | # Show URL and Commit message |
| 501 | # ssh gerrit.opencord.org gerrit query --format=JSON --patch-sets 'projects:voltha-lib-go AND status:open limit:2' | jq '.url,.commitMessage' |
| 502 | ## ----------------------------------------------------------------------- |
| 503 | |
| 504 | # [EOF] |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 505 | |
| 506 | |
| 507 | # 1) gerrit.sh --search --me --wip |
| 508 | # query> owner:joey@opennetworking.org status:open |
| 509 | |
| 510 | # --search --me |
| 511 | # args+=("owner:${USER}@opennetworking.org") |
| 512 | |
| 513 | # --wip) |
| 514 | # argv_status+=('status:open') |
| 515 | # ;; |
| 516 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 517 | # [EOF] |