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