Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 2 | # ------------------------------------------------------------------------- |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 3 | # Copyright 2023-2024 Open Networking Foundation Contributors |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http:#www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # ----------------------------------------------------------------------- |
| 17 | # SPDX-FileCopyrightText: 2023-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 19 | ## -------------------------------------------------------------------- |
| 20 | ## Intent: Construct a jira ticket query with attributes |
| 21 | ## -------------------------------------------------------------------- |
| 22 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 23 | { # loader |
| 24 | declare pgm='' |
| 25 | pgm="$(realpath --canonicalize-existing "$0")" |
| 26 | |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 27 | # stack-trace-on-error |
| 28 | # interrupt handler |
| 29 | # mkdir with auto-cleanup at exit |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 30 | declare root='' |
| 31 | root="${pgm%%/jira/bin/jira-search.sh}" |
| 32 | source "$root/lf/onf-common/common.sh" '--common-args-begin--' |
| 33 | |
| 34 | pgm_lib="${root}/jira/jira-search" |
| 35 | readonly pgm_lib |
| 36 | |
| 37 | pgm_bin="${root}/bin" |
| 38 | readonly pgm_bin |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 39 | |
| 40 | pgm_help="${root}/jira/jira-search/help" |
| 41 | readonly pgm_help |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 42 | } |
| 43 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 44 | # set -euo pipefail |
| 45 | #source ~/.sandbox/trainlab-common/common.sh '--common-args-begin--' |
| 46 | |
| 47 | ##-------------------## |
| 48 | ##---] GLOBALS [---## |
| 49 | ##-------------------## |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 50 | declare -g -a is_empty=() # label |
| 51 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 52 | declare -g -a text=() |
| 53 | declare -g -a text_and=() |
| 54 | declare -g -a text_or=() |
| 55 | |
| 56 | declare -g -a urls_raw=() |
| 57 | declare -g -a urls_filt=() |
| 58 | |
| 59 | declare -g -a labels_incl=() |
| 60 | declare -g -a labels_excl=() |
| 61 | |
| 62 | declare -g -a projects=() |
| 63 | |
| 64 | path="$(realpath $0 --canonicalize-existing)" |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 65 | source "${pgm_lib}/utils.sh" |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 66 | source "${pgm_lib}/include.sh" |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 67 | source "${pgm_lib}/fixversion.sh" |
| 68 | source "${pgm_lib}/resolved.sh" |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 69 | source "${pgm_lib}/help/utils.sh" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 70 | |
| 71 | ## -------------------------------------------------------------------- |
| 72 | ## -------------------------------------------------------------------- |
| 73 | function error() |
| 74 | { |
Joey Armstrong | c5542fa | 2024-03-25 11:49:47 -0400 | [diff] [blame] | 75 | cat <<ERROR |
| 76 | |
| 77 | ** ----------------------------------------------------------------------- |
| 78 | ** IAM: ${FUNCNAME[1]} |
| 79 | ** ERROR: $@ |
| 80 | ** ----------------------------------------------------------------------- |
| 81 | ERROR |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 82 | echo |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 83 | exit 1 |
| 84 | } |
| 85 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 86 | ## -------------------------------------------------------------------- |
| 87 | ## -------------------------------------------------------------------- |
| 88 | function banner() |
| 89 | { |
| 90 | cat <<MSG |
| 91 | |
| 92 | ** ----------------------------------------------------------------------- |
| 93 | ** $@ |
| 94 | ** ----------------------------------------------------------------------- |
| 95 | MSG |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | ## ----------------------------------------------------------------------- |
| 100 | ## Intent: Append a conditional token in the list based on context |
| 101 | ## ----------------------------------------------------------------------- |
| 102 | function and_or() |
| 103 | { |
| 104 | local -n ref=$1; shift |
| 105 | local val="$1" ; shift |
| 106 | |
| 107 | if [[ ${#ref[@]} -gt 0 ]]; then |
| 108 | if [[ -v bool_or ]]; then |
| 109 | ref+=('OR') |
| 110 | else |
| 111 | ref+=('AND') |
| 112 | fi |
| 113 | fi |
| 114 | |
| 115 | ref+=("$val") |
| 116 | return |
| 117 | } |
| 118 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 119 | ## ----------------------------------------------------------------------- |
| 120 | ## ----------------------------------------------------------------------- |
| 121 | function html_encode() |
| 122 | { |
| 123 | local -n ref=$1; shift |
| 124 | local tmp="$ref" |
| 125 | |
| 126 | tmp="${tmp//[[:space:]]/%20}" |
| 127 | tmp="${tmp//\"/%22}" |
| 128 | tmp="${tmp//\'/%27}" |
| 129 | |
| 130 | ref="$tmp" |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | ## ----------------------------------------------------------------------- |
| 135 | ## Intent: Insert a conjunction into the stream when prior statements exist |
| 136 | ## ----------------------------------------------------------------------- |
| 137 | function conjunction() |
| 138 | { |
| 139 | return |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 140 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 141 | local -n ref=$1; shift |
| 142 | [[ $# -gt 0 ]] && { local literal="$1"; shift; } |
| 143 | |
| 144 | ## ------------------------------- |
| 145 | ## Conjunction if prior statements |
| 146 | ## ------------------------------- |
| 147 | if [ ${#ref[@]} -gt 0 ]; then |
| 148 | if [[ -v literal ]]; then |
| 149 | ref+=("$literal") |
| 150 | elif [[ -v bool_and ]]; then |
| 151 | ref+=('AND') |
| 152 | else |
| 153 | ref+=('OR') |
| 154 | fi |
| 155 | fi |
| 156 | |
| 157 | return |
| 158 | } |
| 159 | |
| 160 | ## ----------------------------------------------------------------------- |
| 161 | ## Intent: Helper method |
| 162 | ## ----------------------------------------------------------------------- |
| 163 | ## Usage : local path="$(join_by '/' 'lib' "${fields[@]}")" |
| 164 | ## ----------------------------------------------------------------------- |
| 165 | function join_by() |
| 166 | { |
| 167 | local d=${1-} f=${2-}; if shift 2; then printf %s "$f" "${@/#/$d}"; fi; |
| 168 | } |
| 169 | |
| 170 | ## -------------------------------------------------------------------- |
| 171 | ## Intent: Query by component name filter |
| 172 | ## -------------------------------------------------------------------- |
| 173 | ## Value: helm-charts |
| 174 | ## -------------------------------------------------------------------- |
| 175 | function do_components() |
| 176 | { |
| 177 | declare -n args=$1; shift |
| 178 | declare -n ans=$1; shift |
| 179 | |
| 180 | # [ -z ${args+word} ] && { args=(); } |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 181 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 182 | if [[ ${#args[@]} -gt 0 ]]; then |
| 183 | |
| 184 | local modifier |
| 185 | if [[ -v bool_not ]]; then |
| 186 | modifier='NOT IN' |
| 187 | else |
| 188 | modifier='IN' |
| 189 | fi |
| 190 | ans+=("component ${modifier} (${args[@]})") |
| 191 | # alt: comp='foo' OR comp='bar' |
| 192 | fi |
| 193 | |
| 194 | return |
| 195 | } |
| 196 | |
| 197 | ## -------------------------------------------------------------------- |
| 198 | ## Intent: Query filter by labels assigned to a ticket: |
| 199 | ## o pods, failing, testing |
| 200 | ## -------------------------------------------------------------------- |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 201 | ## Perform a few string joins |
| 202 | ## - elements {in,not-in} label {excl, incl} |
| 203 | ## - OR: is-empty + in-label |
| 204 | ## - AND: excl + incl |
| 205 | ## -------------------------------------------------------------------- |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 206 | # "project in (UKSCR, COMPRG) AND issuetype = Bug AND labels in (BAT)" and |
| 207 | ## -------------------------------------------------------------------- |
| 208 | function do_labels() |
| 209 | { |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 210 | local -n incl=$1; shift # was args= |
| 211 | local -n excl=$1; shift |
| 212 | local -n ans=$1; shift |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 213 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 214 | ## ------------------------------- |
| 215 | ## Join #1: is-empty + labels-incl |
| 216 | ## ------------------------------- |
| 217 | local -a tokens=() |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 218 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 219 | if [[ " ${is_empty[*]} " =~ ' label ' ]]; then |
| 220 | tokens+=('(labels IS EMPTY)') |
| 221 | fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 222 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 223 | ## ------------------------------ |
| 224 | ## Construct label include filter |
| 225 | ## ------------------------------ |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 226 | if [[ ${#incl[@]} -gt 0 ]]; then |
| 227 | |
| 228 | local modifier |
| 229 | if [[ -v bool_not ]]; then |
| 230 | modifier='NOT IN' |
| 231 | else |
| 232 | modifier='IN' |
| 233 | fi |
| 234 | |
| 235 | local labels=$(join_by ',' "${incl[@]}") |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 236 | tokens+=("(labels ${modifier} ($labels))") |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 237 | fi |
| 238 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 239 | # ------------------------------ |
| 240 | # JOIN[OR]: is-empty + in-labels |
| 241 | # ------------------------------ |
| 242 | if [[ ${#tokens[@]} -gt 1 ]]; then |
| 243 | local combine |
| 244 | combine=("$(join_by ' OR ' "${tokens[@]}")") |
| 245 | tokens=("$combine") |
| 246 | fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 247 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 248 | ## ------------------------------ |
| 249 | ## Construct label exclude filter |
| 250 | ## ------------------------------ |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 251 | if [[ ${#excl[@]} -gt 0 ]]; then |
| 252 | local labels=$(join_by ',' "${excl[@]}") |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 253 | tokens+=("(labels NOT IN ($labels))") |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 254 | fi |
| 255 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 256 | # ------------------------------------ |
| 257 | # JOIN[AND]: labels-excl + labels-incl |
| 258 | # ------------------------------------ |
| 259 | if [[ ${#tokens[@]} -gt 1 ]]; then |
| 260 | tokens=("$(join_by ' AND ' "${tokens[@]}")") |
| 261 | fi |
| 262 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 263 | ans+=("${tokens[@]}") |
| 264 | return |
| 265 | } |
| 266 | |
| 267 | ## -------------------------------------------------------------------- |
| 268 | ## Intent: Modify search query by project type (SEBA, VOL) |
| 269 | ## -------------------------------------------------------------------- |
| 270 | function do_projects() |
| 271 | { |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 272 | local -n ref=$1; shift |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 273 | |
| 274 | [[ ${#projects[@]} -eq 0 ]] && { return; } |
| 275 | |
| 276 | local terms="$(join_by ',' "${projects[@]}")" |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 277 | # local -a buffer=('(' 'project' 'IN' "($terms)" ')') |
| 278 | # ref+=("$(join_by '%20' "${buffer[@]}")") |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 279 | ref+=("(project IN ($terms))") |
| 280 | return |
| 281 | } |
| 282 | |
| 283 | ## -------------------------------------------------------------------- |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 284 | ## Intent: Construct query using text field filters |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 285 | ## -------------------------------------------------------------------- |
| 286 | function do_text() |
| 287 | { |
| 288 | local -n ref=$1; shift |
| 289 | local -n ans=$1; shift |
| 290 | local val |
| 291 | |
| 292 | ## Accumulate |
| 293 | if [[ ${#ref[@]} -gt 0 ]]; then |
| 294 | |
| 295 | if [[ -v bool_and ]]; then |
| 296 | text_and+=("${ref[@]}") |
| 297 | else |
| 298 | text_or+=("${ref[@]}") |
| 299 | fi |
| 300 | fi |
| 301 | |
| 302 | ## Append terms: AND |
| 303 | if [[ ${#text_and[@]} -gt 0 ]]; then |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 304 | local -a term=() |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 305 | for val in "${text_and[@]}"; |
| 306 | do |
| 307 | term+=("text ~ \"$val\"") |
| 308 | done |
| 309 | val=$(join_by ' AND ' "${term[@]}") |
| 310 | ans+=("($val)") |
| 311 | fi |
| 312 | |
| 313 | ## Append terms: OR |
| 314 | if [[ ${#text_or[@]} -gt 0 ]]; then |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 315 | local -a term=() |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 316 | for val in "${text_or[@]}"; |
| 317 | do |
| 318 | term+=("text ~ \"$val\"") |
| 319 | done |
| 320 | val=$(join_by ' OR ' "${term[@]}") |
| 321 | ans+=("($val)") |
| 322 | fi |
| 323 | |
| 324 | return |
| 325 | } |
| 326 | |
| 327 | ## -------------------------------------------------------------------- |
| 328 | ## Intent: Query by assigned or requestor |
| 329 | ## -------------------------------------------------------------------- |
| 330 | ## Note: Simple for now but support query by a list of suers |
| 331 | ## -------------------------------------------------------------------- |
| 332 | function do_user() |
| 333 | { |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 334 | local -n ans=$1; shift |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 335 | |
| 336 | [[ -v argv_nobody ]] && return |
| 337 | |
| 338 | local user='currentUser()' |
| 339 | if [[ -v argv_user ]]; then |
| 340 | user="$argv_user" |
| 341 | fi |
| 342 | |
| 343 | if [[ -v argv_assigned ]]; then |
| 344 | ans+=("assignee=${user}") |
| 345 | fi |
| 346 | |
| 347 | if [[ -v argv_reported ]]; then |
| 348 | ans+=("reporter=${user}") |
| 349 | fi |
| 350 | |
| 351 | return |
| 352 | } |
| 353 | |
| 354 | ## -------------------------------------------------------------------- |
| 355 | ## Intent: Combine filter arguments into a search query |
| 356 | ## -------------------------------------------------------------------- |
| 357 | function gen_filter() |
| 358 | { |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 359 | local -n ans=$1 ; shift |
| 360 | local -n args=$1 ; shift |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 361 | |
| 362 | ## ----------------------------------- |
| 363 | ## Begin by joining major search terms |
| 364 | ## ----------------------------------- |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 365 | local -a _tmp=() |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 366 | local val |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 367 | |
| 368 | local -i is_paren=0 |
| 369 | local -a buffer=() |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 370 | for val in "${args[@]}"; |
| 371 | do |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 372 | case "$val" in |
| 373 | '(') _tmp+=("$val"); continue ;; |
| 374 | ')') _tmp+=("$val"); continue ;; |
| 375 | esac |
| 376 | |
| 377 | and_or _tmp "$val" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 378 | done |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 379 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 380 | ## ---------------------------------------------------------------- |
| 381 | # This was used to remove AND term when a non-query or non-argument |
| 382 | # query was needed. Any lingering logic dependent on it ? |
| 383 | ## ---------------------------------------------------------------- |
| 384 | # if [[ ${#_tmp[@]} -gt 0 ]]; then |
| 385 | # unset _tmp[-1] |
| 386 | # fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 387 | |
| 388 | ## ----------------------- |
| 389 | ## Massage with html codes |
| 390 | ## ----------------------- |
| 391 | ans="$(join_by '%20' "${_tmp[@]}")" |
| 392 | return |
| 393 | } |
| 394 | |
| 395 | ## -------------------------------------------------------------------- |
| 396 | ## Intent: Combine filter arguments into a search query |
| 397 | ## -------------------------------------------------------------------- |
| 398 | function gen_url() |
| 399 | { |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 400 | local -n ans=$1; shift |
| 401 | local -n args=$1; shift |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 402 | |
| 403 | ## Which jira server to query (?) |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 404 | [[ ! -v server ]] && local -g server='jira.opennetworking.org' |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 405 | tmp_url="https://${server}/issues/?jql=" |
| 406 | tmp="${tmp_url}${args}" |
| 407 | ans="${tmp// /%20}" |
| 408 | return |
| 409 | } |
| 410 | |
| 411 | ## -------------------------------------------------------------------- |
| 412 | ## Intent: Dispaly command usage |
| 413 | ## -------------------------------------------------------------------- |
| 414 | function usage() |
| 415 | { |
| 416 | cat <<EOH |
| 417 | Usage: $0 VOL-xxxx |
| 418 | --debug Enable script debug mode |
| 419 | --dry-run Simulate |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 420 | --todo Display future enhancements |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 421 | |
| 422 | VOL-{xxxx} View a jira ticket by ID |
| 423 | |
| 424 | [SERVER] |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 425 | --server {cord,onf} |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 426 | --onf jira.opennetworking.org |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 427 | --opencord jira.opencord.org |
| 428 | |
| 429 | [WHAT] |
| 430 | --component Search by component name assigned to ticket |
| 431 | --label Search by label name assigned to ticket. |
| 432 | --text Search string(s) |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 433 | EOH |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 434 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 435 | # local -a topics=() |
| 436 | # topics+=('fixversion.switches') |
| 437 | # topics+=('resolved.switches') |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 438 | # |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 439 | # help_switch_show "${topics[@]}"# |
| 440 | # |
| 441 | #[USER(s)] |
| 442 | # --me Tickets assigned to or reported by me. |
| 443 | # --user [u] Tickets assigned to this user. |
| 444 | # --nobody Raw query, no filtering by user |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 445 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 446 | |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 447 | cat <<EOH |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 448 | |
| 449 | [BOOL] |
| 450 | --and Join terms using 'AND' |
| 451 | --or Join terms using 'OR' |
| 452 | |
| 453 | [MEMBER] |
| 454 | --in (default) Items belong (--component IN) |
| 455 | --not-in Negate item set (--component NOT IN) |
| 456 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 457 | [Contains] (join modifer: --and, --or, --is-empty) |
| 458 | --text [t] |
| 459 | --text-and [t] All list items |
| 460 | --text-or [t] Any list items |
| 461 | --label [l] Match label field based on modifier criteria |
| 462 | --text-and [t] All list items |
| 463 | --text-or [t] Any list items |
| 464 | |
| 465 | [MODIFIERS] |
| 466 | --and Combine query terms using AND keyword |
| 467 | --or Combine query terms using OR keyword |
| 468 | --in Include ticket field if list item(s) match |
| 469 | --not Negate a query |
| 470 | --is-empty Include ticket if field is empty |
| 471 | --resolved-is-empty |
| 472 | --unresolved Query for open/unresolved jira tickets. |
| 473 | |
| 474 | [FILTER] |
| 475 | --excl Exclude tickets whose fields match this string (filter-out) |
| 476 | --incl Include tickets whose fields match this string |
| 477 | |
| 478 | [--resolved] |
| 479 | --resolved-is-empty |
| 480 | --resolved-start Query by date range |
| 481 | --resolved-end Query by date range |
| 482 | --resolved(-not)-empty Query for (closed)/open tickets |
| 483 | --resolved-excl Types to exclude |
| 484 | --resolved-incl Types to include |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 485 | |
| 486 | [RANGE] |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 487 | --newer [d] Search for tickets created < [n] days ago. |
| 488 | --older [d] Search for tickets created > [n] days ago. |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 489 | |
| 490 | [ALIASES] |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 491 | --all Query for all unresolved tickets |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 492 | --unresolved Alias for --resolved-is-empty |
| 493 | --wip Alias for --resolved-is-empty |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 494 | |
| 495 | [TOPIC] |
| 496 | --fixversion Query by field: fixedversion |
| 497 | --resolved Query by field: resolved |
| 498 | --user Query by owner, requestor or 'my' jira tickets. |
| 499 | |
| 500 | [HELP] |
| 501 | --help This message |
| 502 | --help-{topic} Display switch help and use case. (--help-resolved) |
| 503 | --usage-{topic} Display use cases for a given switch (--usage-user) |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 504 | |
| 505 | [USAGE] |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 506 | $0 --opencord --assigned --unresolved |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 507 | o Display all tickets assigned to my login |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 508 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 509 | $0 --reported --or --text 'bbsim' --text 'release' |
| 510 | o Search for tickets that contain strings bbsim or release |
| 511 | $0 --cord --text-and 'release' --text-and 'voltctl' |
| 512 | o Search jira.opencord for tickets that contain release and voltctl |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 513 | |
| 514 | $0 --cord --label failing --label pod |
| 515 | o Search jira.opencord for tests failing due to pod/hardware issuses. |
| 516 | |
| 517 | $0 --proj VOL --fixversion "VOLTHA v2.12" --resolved-is-empty |
| 518 | o Query for unresolved release tickets |
| 519 | EOH |
| 520 | |
| 521 | return |
| 522 | } |
| 523 | |
| 524 | ## -------------------------------------------------------------------- |
| 525 | # classpath=$(join_by ':' "${mypath[@]}") |
| 526 | ## -------------------------------------------------------------------- |
| 527 | function join_by() |
| 528 | { |
| 529 | local d=${1-} f=${2-}; if shift 2; then printf %s "$f" "${@/#/$d}"; fi; |
| 530 | } |
| 531 | |
| 532 | ##----------------## |
| 533 | ##---] MAIN [---## |
| 534 | ##----------------## |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 535 | declare -a suffix0=() # accumulated terms to join |
| 536 | declare server='jira.opencord.org' |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 537 | |
| 538 | # declare -g -i debug=1 |
| 539 | |
| 540 | while [ $# -gt 0 ]; do |
| 541 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 542 | # if [ ${#suffix0[@]} -gt 0 ]; then |
| 543 | # suffix0+=('AND') |
| 544 | # fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 545 | |
| 546 | arg="$1"; shift |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 547 | banner "ARG=[$arg], \$@=[$@]" |
| 548 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 549 | [[ -v debug ]] && echo "** argv=[$arg] [$*]" |
| 550 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 551 | getopt_detect_modifiers "$arg" |
| 552 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 553 | case "$arg" in |
| 554 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 555 | '--help') usage; exit 0 ;; |
| 556 | '--help-'*) help_with "${arg/--help-/}" ;; |
| 557 | '--usage-'*) help_usage_show "${arg/--usage-/}" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 558 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 559 | '--'*'-is-empty') |
| 560 | declare -a args=() |
| 561 | args+=('--is-empty') |
| 562 | |
| 563 | arg="${arg:2}" # remove prefix -- |
| 564 | arg="${arg%-is-empty}" # remove suffix token-name |
| 565 | args+=("$arg") |
| 566 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 567 | |
| 568 | set -- "${args[@]}" |
| 569 | ;; |
| 570 | |
| 571 | '--is-empty') |
| 572 | declare val="$1"; shift |
| 573 | declare -a valid=() |
| 574 | valid+=('label') |
| 575 | |
| 576 | if [[ " ${valid[@]} " =~ " ${val} " ]]; then |
| 577 | is_empty+=("$val") |
| 578 | else |
| 579 | error "Detected invalid --is-empty switch [$arg]" |
| 580 | fi |
| 581 | ;; |
| 582 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 583 | ##-----------------## |
| 584 | ##---] MODES [---## |
| 585 | ##-----------------## |
| 586 | -*debug) declare -g -i debug=1 ;; |
| 587 | --dry-run) declare -g -i dry_run=1 ;; |
| 588 | |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 589 | ##------------------------## |
| 590 | ##---] SWITCH ALIAS [---## |
| 591 | ##------------------------## |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 592 | --unresolved|--wip) |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 593 | declare -a args=() |
| 594 | args+=('--resolved-is-empty') |
| 595 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 596 | set -- "${args[@]}" |
| 597 | ;; |
| 598 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 599 | ##-------------------## |
| 600 | ##---] BY USER [---## |
| 601 | ##-------------------## |
| 602 | --assigned) declare -g -i argv_assigned=1 ;; |
| 603 | --reported) declare -g -i argv_reported=1 ;; |
| 604 | --me) declare -g -i argv_me=1 ;; |
| 605 | --nobody) declare -g -i argv_nobody=1 ;; |
| 606 | --user) |
| 607 | arg="$1"; shift |
| 608 | declare -g argv_user="$arg" |
| 609 | ;; |
| 610 | |
| 611 | ##------------------## |
| 612 | ##---] SERVER [---## |
| 613 | ##------------------## |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 614 | --serv*) |
| 615 | arg="$1"; shift |
| 616 | case "$arg" in |
| 617 | *cord*) server='jira.opencord.org' ;; |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 618 | *onf*) server='jira.opennetworking.org' ;; |
| 619 | *) error "--server [$arg] expected opencord or onf" ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 620 | esac |
| 621 | ;; |
| 622 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 623 | --onf) declare server='jira.opennetworking.org' ;; |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 624 | --opencord) declare server='jira.opencord.org' ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 625 | |
| 626 | ##---------------------## |
| 627 | ##---] SEARCH-BY [---## |
| 628 | ##---------------------## |
| 629 | --component|--comp*) |
| 630 | arg="$1"; shift |
| 631 | [[ ! -v components ]] && declare -g -a components=() |
| 632 | components+=("$arg") |
| 633 | ;; |
| 634 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 635 | '--label-is-empty') is_empty+=('label') ;; |
| 636 | |
| 637 | '--label'|'--lab'*) |
| 638 | val="$1"; shift |
| 639 | if [[ -v getopt_argv_EXCL ]]; then |
| 640 | labels_excl+=("$val") |
| 641 | elif [[ -v getopt_argv_INCL ]]; then |
| 642 | labels_incl+=("$val") |
| 643 | else |
| 644 | labels_incl+=("$val") |
| 645 | fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 646 | ;; |
| 647 | |
| 648 | ##-----------------------## |
| 649 | ##---] Text Search [---## |
| 650 | ##-----------------------## |
| 651 | # jsearch.sh --text-and bbsim --text-and release |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 652 | '--tex'*) |
| 653 | [[ $# -gt 0 ]] && { val="$1"; } |
| 654 | case "$arg" in |
| 655 | '--text-and') text_and+=("$val") ;; |
| 656 | '--text-or') text_or+=("$val") ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 657 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 658 | # % js --and --text jenkins --text cord |
| 659 | # text ~ "Jira Software" # [WORDs] |
| 660 | # text ~ "\"Jira Software\"" # [STRING] |
| 661 | '--text') |
| 662 | if [[ ! -v bool_and_or ]]; then |
| 663 | error "Qualify [$arg] using --text-{and,or}" |
| 664 | elif [[ bool_and_or -eq 1 ]]; then |
| 665 | text_and+=("$1"); shift |
| 666 | elif [[ bool_and_or -eq 0 ]]; then |
| 667 | text_or+=("$1"); shift |
| 668 | else |
| 669 | error "Qualify [$arg] using --text-{and,or}" |
| 670 | fi |
| 671 | ;; |
| 672 | *) error "Qualify [$arg] using --text-{and,or}" ;; |
| 673 | esac |
| 674 | shift # $val |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 675 | ;; |
| 676 | |
| 677 | --all) set -- '--resolved-is-none' "$@" ;; # alias: --[un-]resolved |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 678 | --todo) source "${pgm_lib}/todo.sh" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 679 | |
| 680 | --proj*) projects+=("$1"); shift ;; |
| 681 | |
| 682 | --fixversion-*) |
| 683 | # function get_jql_fixversion() |
| 684 | case "$arg" in |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 685 | *excl) |
| 686 | [[ ! -v fixversion_excl ]] && { declare -g -a fixversion_excl=(); } |
| 687 | val="\"$1\""; shift |
| 688 | html_encode val |
| 689 | fixversion_excl+=("$val"); |
| 690 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 691 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 692 | *incl) |
| 693 | [[ ! -v fixversion_incl ]] && { declare -g -a fixversion_incl=(); } |
| 694 | val="\"$1\""; shift |
| 695 | html_encode val |
| 696 | fixversion_incl+=("$val"); |
| 697 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 698 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 699 | *not-empty) declare -g -i fixversion_not_empty=1 ;; |
| 700 | *is-empty) declare -g -i fixversion_is_empty=1 ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 701 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 702 | *) error "Detected invalid --fixversion-* modifier" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 703 | esac |
| 704 | ;; |
| 705 | |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 706 | '--resolved-'*) |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 707 | # function get_jql_reasons() |
| 708 | case "$arg" in |
| 709 | |
| 710 | *start) declare -g resolved_start="$1"; shift ;; |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 711 | *end) declare -g resolved_end="$1"; shift ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 712 | |
| 713 | *not-empty) declare -g resolved_not_empty="$1" ;; |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 714 | *empty) declare -g resolved_is_empty="$1" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 715 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 716 | *excl) |
| 717 | [[ ! -v resolved_excl ]] && { declare -g -a resolved_excl=(); } |
| 718 | val="\"$1\""; shift |
| 719 | html_encode val |
| 720 | resolved_excl+=("$val"); |
| 721 | ;; |
| 722 | *incl) |
| 723 | [[ ! -v resolved_incl ]] && { declare -g -a resolved_incl=(); } |
| 724 | val="\"$1\""; shift |
| 725 | html_encode val |
| 726 | resolved_incl+=("$val"); |
| 727 | ;; |
| 728 | *) ;; |
| 729 | *) error "Detected invalid --resolved-* modifier" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 730 | esac |
| 731 | ;; |
| 732 | |
| 733 | -*newer) |
| 734 | arg="$1"; shift |
| 735 | suffix0+=("created <= '-${arg}d'") ;; |
| 736 | |
| 737 | -*older) |
| 738 | arg="$1"; shift |
| 739 | suffix0+=("created >= '-${arg}d'") ;; |
| 740 | |
| 741 | ##----------------## |
| 742 | ##---] BOOL [---## |
| 743 | ##----------------## |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 744 | --[aA][nN][dD]) |
| 745 | declare -g -i bool_and=1 |
| 746 | declare -g -i bool_and_or=1 # ! -v else toggle |
| 747 | ;; |
| 748 | --[oO][rR]) |
| 749 | declare -g -i bool_or=1 |
| 750 | declare -g -i bool_and_or=0 |
| 751 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 752 | |
| 753 | ##------------------## |
| 754 | ##---] MEMBER [---## |
| 755 | ##------------------## |
| 756 | --[iI][nN]) declare -g -i bool_in=1 ;; |
| 757 | --[nN][oO][tT]) declare -g -i bool_not=1 ;; |
| 758 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 759 | [A-Z][A-Z][A-Z]-[0-9]*) # VOL-xxxx (jira ticket) |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 760 | case "$arg" in |
| 761 | CORD-[0-9]*) |
| 762 | url="https://jira.opencord.org/browse/${arg}" |
| 763 | urls_raw+=('--new-window' "$url") |
| 764 | ;; |
| 765 | |
| 766 | INF-[0-9]*) |
| 767 | url="https://jira.opennetworking.org/browse/${arg}" |
| 768 | urls_raw+=('--new-window' "$url") |
| 769 | ;; |
| 770 | |
| 771 | VOL-[0-9]*) |
| 772 | url="https://jira.opencord.org/browse/${arg}" |
| 773 | urls_raw+=('--new-window' "$url") |
| 774 | ;; |
| 775 | |
| 776 | *) error "Detected invalid ticket [$arg]" ;; |
| 777 | |
| 778 | esac |
| 779 | ;; |
| 780 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 781 | ## --------------------------- |
| 782 | ## Search all fields for value |
| 783 | ## --------------------------- |
| 784 | [[:word:]]*) |
| 785 | |
| 786 | echo "MATCHED: [$arg] (LINENO: $LINENO)" |
| 787 | declare -a args=() |
| 788 | args+=('--OR') |
| 789 | args+=('--component' "$arg") |
| 790 | args+=('--label-incl' "$arg") |
| 791 | args+=('--text-or' "$arg") |
| 792 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 793 | set -- "${args[@]}" |
| 794 | ;; |
| 795 | |
| 796 | -*) error "Detected unknown switch [$arg]" ;; |
| 797 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 798 | # ----------------------------------------------------------------------- |
| 799 | # https://support.atlassian.com/jira-software-cloud/docs/search-syntax-for-text-fields/ |
| 800 | # ----------------------------------------------------------------------- |
| 801 | # +jira atlassian -- must contain jira, atlassian is optional |
| 802 | # -japan -- exclude term |
| 803 | # [STEM] summary ~ "customize" -- finds stem 'custom' in the Summary field |
| 804 | *) |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 805 | echo "MATCHED: [$arg] (LINENO: $LINENO)" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 806 | declare -p text_and |
| 807 | error "Detected unknown argument $arg" |
| 808 | ;; |
| 809 | esac |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 810 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 811 | done |
| 812 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 813 | ## -------------- |
| 814 | ## Required check |
| 815 | ## -------------- |
| 816 | [[ ! -v server ]] && { error "--server={cord,onf} is required"; } |
| 817 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 818 | ## ---------------------- |
| 819 | ## Construct query filter |
| 820 | ## ---------------------- |
| 821 | do_user suffix0 |
| 822 | do_projects suffix0 |
| 823 | [[ -v components ]] && { do_components components suffix0; } |
| 824 | do_labels labels_incl labels_excl suffix0 |
| 825 | do_text text suffix0 |
| 826 | do_resolved suffix0 |
| 827 | do_fixversion suffix0 |
| 828 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame^] | 829 | declare -p suffix0 |
| 830 | |
| 831 | if [[ -v getopt_argv_AND ]]; then |
| 832 | query="$(join_by 'AND' "${suffix0[0]}")" |
| 833 | elif [[ -v getopt_argv_OR ]]; then |
| 834 | query="$(join_by 'OR' "${suffix0[0]}")" |
| 835 | else |
| 836 | error "Ambiguous query [argv needs: --and or --or]" |
| 837 | fi |
| 838 | |
| 839 | # banner "$(declare -p query)" |
| 840 | |
| 841 | |
| 842 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 843 | filter='' |
| 844 | gen_filter filter suffix0 |
| 845 | |
| 846 | if [[ ! -v urls_raw ]]; then |
| 847 | url='' |
| 848 | gen_url url filter |
| 849 | urls_filt+=("$url") |
| 850 | elif [ ${#urls_raw} -eq 0 ]; then |
| 851 | url='' |
| 852 | gen_url url filter |
| 853 | urls_filt+=("$url") |
| 854 | fi |
| 855 | |
| 856 | [[ -v debug ]] && [[ -v url ]] && echo "URL: $url" |
Joey Armstrong | e4ef06a | 2024-03-22 11:43:54 -0400 | [diff] [blame] | 857 | browser="${BROWSER:-firefox}" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 858 | echo "$browser ${urls_filt[@]} ${urls_raw[@]}" |
| 859 | |
| 860 | if [[ ! -v dry_run ]]; then |
| 861 | "$browser" "${urls_filt[@]}" "${urls_raw[@]}" >/dev/null 2>/dev/null & |
| 862 | fi |
| 863 | |
| 864 | # [SEE ALSO] |
| 865 | # o https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-fields/ |
| 866 | |
| 867 | # [EOF] |