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 | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 542 | arg="$1"; shift |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 543 | banner "ARG=[$arg], \$@=[$@]" |
| 544 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 545 | [[ -v debug ]] && echo "** argv=[$arg] [$*]" |
| 546 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 547 | getopt_detect_modifiers "$arg" |
| 548 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 549 | case "$arg" in |
| 550 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 551 | '--help') usage; exit 0 ;; |
| 552 | '--help-'*) help_with "${arg/--help-/}" ;; |
| 553 | '--usage-'*) help_usage_show "${arg/--usage-/}" ;; |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 554 | |
| 555 | *'-is-empty'*) |
| 556 | is_switch_valid__is_empty "$arg" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 557 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 558 | declare -a args=() |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 559 | arg="${arg:2}" # remove prefix -- |
| 560 | arg="${arg%-is-empty}" # remove suffix token-name |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 561 | |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 562 | ## Rewrite switch to bypass is-empty and match --required |
| 563 | args+=("--${arg}+is-empty") # ARGV: gen JCL tokens |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 564 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 565 | |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 566 | set -- "${args[@]}" # --is-empty resolved |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 567 | ;; |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 568 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 569 | ##-----------------## |
| 570 | ##---] MODES [---## |
| 571 | ##-----------------## |
| 572 | -*debug) declare -g -i debug=1 ;; |
| 573 | --dry-run) declare -g -i dry_run=1 ;; |
| 574 | |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 575 | ##------------------------## |
| 576 | ##---] SWITCH ALIAS [---## |
| 577 | ##------------------------## |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 578 | --unresolved|--wip) |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 579 | declare -a args=() |
| 580 | args+=('--resolved-is-empty') |
| 581 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 582 | set -- "${args[@]}" |
| 583 | ;; |
| 584 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 585 | ##-------------------## |
| 586 | ##---] BY USER [---## |
| 587 | ##-------------------## |
| 588 | --assigned) declare -g -i argv_assigned=1 ;; |
| 589 | --reported) declare -g -i argv_reported=1 ;; |
| 590 | --me) declare -g -i argv_me=1 ;; |
| 591 | --nobody) declare -g -i argv_nobody=1 ;; |
| 592 | --user) |
| 593 | arg="$1"; shift |
| 594 | declare -g argv_user="$arg" |
| 595 | ;; |
| 596 | |
| 597 | ##------------------## |
| 598 | ##---] SERVER [---## |
| 599 | ##------------------## |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 600 | --serv*) |
| 601 | arg="$1"; shift |
| 602 | case "$arg" in |
| 603 | *cord*) server='jira.opencord.org' ;; |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 604 | *onf*) server='jira.opennetworking.org' ;; |
| 605 | *) error "--server [$arg] expected opencord or onf" ;; |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 606 | esac |
| 607 | ;; |
| 608 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 609 | --onf) declare server='jira.opennetworking.org' ;; |
Joey Armstrong | cc24b3c | 2024-03-22 11:12:23 -0400 | [diff] [blame] | 610 | --opencord) declare server='jira.opencord.org' ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 611 | |
| 612 | ##---------------------## |
| 613 | ##---] SEARCH-BY [---## |
| 614 | ##---------------------## |
| 615 | --component|--comp*) |
| 616 | arg="$1"; shift |
| 617 | [[ ! -v components ]] && declare -g -a components=() |
| 618 | components+=("$arg") |
| 619 | ;; |
| 620 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 621 | '--label-is-empty') is_empty+=('label') ;; |
| 622 | |
| 623 | '--label'|'--lab'*) |
| 624 | val="$1"; shift |
| 625 | if [[ -v getopt_argv_EXCL ]]; then |
| 626 | labels_excl+=("$val") |
| 627 | elif [[ -v getopt_argv_INCL ]]; then |
| 628 | labels_incl+=("$val") |
| 629 | else |
| 630 | labels_incl+=("$val") |
| 631 | fi |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 632 | ;; |
| 633 | |
| 634 | ##-----------------------## |
| 635 | ##---] Text Search [---## |
| 636 | ##-----------------------## |
| 637 | # jsearch.sh --text-and bbsim --text-and release |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 638 | '--tex'*) |
| 639 | [[ $# -gt 0 ]] && { val="$1"; } |
| 640 | case "$arg" in |
| 641 | '--text-and') text_and+=("$val") ;; |
| 642 | '--text-or') text_or+=("$val") ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 643 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 644 | # % js --and --text jenkins --text cord |
| 645 | # text ~ "Jira Software" # [WORDs] |
| 646 | # text ~ "\"Jira Software\"" # [STRING] |
| 647 | '--text') |
| 648 | if [[ ! -v bool_and_or ]]; then |
| 649 | error "Qualify [$arg] using --text-{and,or}" |
| 650 | elif [[ bool_and_or -eq 1 ]]; then |
| 651 | text_and+=("$1"); shift |
| 652 | elif [[ bool_and_or -eq 0 ]]; then |
| 653 | text_or+=("$1"); shift |
| 654 | else |
| 655 | error "Qualify [$arg] using --text-{and,or}" |
| 656 | fi |
| 657 | ;; |
| 658 | *) error "Qualify [$arg] using --text-{and,or}" ;; |
| 659 | esac |
| 660 | shift # $val |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 661 | ;; |
| 662 | |
| 663 | --all) set -- '--resolved-is-none' "$@" ;; # alias: --[un-]resolved |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 664 | --todo) source "${pgm_lib}/todo.sh" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 665 | |
| 666 | --proj*) projects+=("$1"); shift ;; |
| 667 | |
| 668 | --fixversion-*) |
| 669 | # function get_jql_fixversion() |
| 670 | case "$arg" in |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 671 | *excl) |
| 672 | [[ ! -v fixversion_excl ]] && { declare -g -a fixversion_excl=(); } |
| 673 | val="\"$1\""; shift |
| 674 | html_encode val |
| 675 | fixversion_excl+=("$val"); |
| 676 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 677 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 678 | *incl) |
| 679 | [[ ! -v fixversion_incl ]] && { declare -g -a fixversion_incl=(); } |
| 680 | val="\"$1\""; shift |
| 681 | html_encode val |
| 682 | fixversion_incl+=("$val"); |
| 683 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 684 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 685 | *not-empty) declare -g -i fixversion_not_empty=1 ;; |
| 686 | *is-empty) declare -g -i fixversion_is_empty=1 ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 687 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 688 | *) error "Detected invalid --fixversion-* modifier" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 689 | esac |
| 690 | ;; |
| 691 | |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 692 | '--resolved'*) # [-+] |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 693 | # function get_jql_reasons() |
| 694 | case "$arg" in |
| 695 | |
| 696 | *start) declare -g resolved_start="$1"; shift ;; |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 697 | *end) declare -g resolved_end="$1"; shift ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 698 | |
| 699 | *not-empty) declare -g resolved_not_empty="$1" ;; |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 700 | *'empty') |
| 701 | banner "Detected [$arg]" |
| 702 | declare -g resolved_is_empty="$1" |
| 703 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 704 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 705 | *excl) |
| 706 | [[ ! -v resolved_excl ]] && { declare -g -a resolved_excl=(); } |
| 707 | val="\"$1\""; shift |
| 708 | html_encode val |
| 709 | resolved_excl+=("$val"); |
| 710 | ;; |
| 711 | *incl) |
| 712 | [[ ! -v resolved_incl ]] && { declare -g -a resolved_incl=(); } |
| 713 | val="\"$1\""; shift |
| 714 | html_encode val |
| 715 | resolved_incl+=("$val"); |
| 716 | ;; |
| 717 | *) ;; |
| 718 | *) error "Detected invalid --resolved-* modifier" ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 719 | esac |
| 720 | ;; |
| 721 | |
| 722 | -*newer) |
| 723 | arg="$1"; shift |
| 724 | suffix0+=("created <= '-${arg}d'") ;; |
| 725 | |
| 726 | -*older) |
| 727 | arg="$1"; shift |
| 728 | suffix0+=("created >= '-${arg}d'") ;; |
| 729 | |
| 730 | ##----------------## |
| 731 | ##---] BOOL [---## |
| 732 | ##----------------## |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 733 | --[aA][nN][dD]) |
| 734 | declare -g -i bool_and=1 |
| 735 | declare -g -i bool_and_or=1 # ! -v else toggle |
| 736 | ;; |
| 737 | --[oO][rR]) |
| 738 | declare -g -i bool_or=1 |
| 739 | declare -g -i bool_and_or=0 |
| 740 | ;; |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 741 | |
| 742 | ##------------------## |
| 743 | ##---] MEMBER [---## |
| 744 | ##------------------## |
| 745 | --[iI][nN]) declare -g -i bool_in=1 ;; |
| 746 | --[nN][oO][tT]) declare -g -i bool_not=1 ;; |
| 747 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 748 | [A-Z][A-Z][A-Z]-[0-9]*) # VOL-xxxx (jira ticket) |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 749 | case "$arg" in |
| 750 | CORD-[0-9]*) |
| 751 | url="https://jira.opencord.org/browse/${arg}" |
| 752 | urls_raw+=('--new-window' "$url") |
| 753 | ;; |
| 754 | |
| 755 | INF-[0-9]*) |
| 756 | url="https://jira.opennetworking.org/browse/${arg}" |
| 757 | urls_raw+=('--new-window' "$url") |
| 758 | ;; |
| 759 | |
| 760 | VOL-[0-9]*) |
| 761 | url="https://jira.opencord.org/browse/${arg}" |
| 762 | urls_raw+=('--new-window' "$url") |
| 763 | ;; |
| 764 | |
| 765 | *) error "Detected invalid ticket [$arg]" ;; |
| 766 | |
| 767 | esac |
| 768 | ;; |
| 769 | |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 770 | ## --------------------------- |
| 771 | ## Search all fields for value |
| 772 | ## --------------------------- |
| 773 | [[:word:]]*) |
| 774 | |
| 775 | echo "MATCHED: [$arg] (LINENO: $LINENO)" |
| 776 | declare -a args=() |
| 777 | args+=('--OR') |
| 778 | args+=('--component' "$arg") |
| 779 | args+=('--label-incl' "$arg") |
| 780 | args+=('--text-or' "$arg") |
| 781 | [[ $# -gt 0 ]] && { args+=("$@"); } |
| 782 | set -- "${args[@]}" |
| 783 | ;; |
| 784 | |
| 785 | -*) error "Detected unknown switch [$arg]" ;; |
| 786 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 787 | # ----------------------------------------------------------------------- |
| 788 | # https://support.atlassian.com/jira-software-cloud/docs/search-syntax-for-text-fields/ |
| 789 | # ----------------------------------------------------------------------- |
| 790 | # +jira atlassian -- must contain jira, atlassian is optional |
| 791 | # -japan -- exclude term |
| 792 | # [STEM] summary ~ "customize" -- finds stem 'custom' in the Summary field |
| 793 | *) |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 794 | echo "MATCHED: [$arg] (LINENO: $LINENO)" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 795 | declare -p text_and |
| 796 | error "Detected unknown argument $arg" |
| 797 | ;; |
| 798 | esac |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 799 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 800 | done |
| 801 | |
Joey Armstrong | 76f861a | 2024-03-13 16:01:24 -0400 | [diff] [blame] | 802 | ## -------------- |
| 803 | ## Required check |
| 804 | ## -------------- |
| 805 | [[ ! -v server ]] && { error "--server={cord,onf} is required"; } |
| 806 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 807 | ## ---------------------- |
| 808 | ## Construct query filter |
| 809 | ## ---------------------- |
| 810 | do_user suffix0 |
| 811 | do_projects suffix0 |
| 812 | [[ -v components ]] && { do_components components suffix0; } |
| 813 | do_labels labels_incl labels_excl suffix0 |
| 814 | do_text text suffix0 |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 815 | |
| 816 | get_jcl_resolved suffix0 |
| 817 | # do_resolved suffix0 |
| 818 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 819 | do_fixversion suffix0 |
| 820 | |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 821 | declare -p getopt_argv_any_OR |
| 822 | if [[ -v getopt_argv_any_OR ]]; then |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 823 | query="$(join_by 'OR' "${suffix0[0]}")" |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 824 | elif [[ -v getopt_argv_any_AND ]]; then |
| 825 | query="$(join_by 'AND' "${suffix0[0]}")" |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 826 | else |
Joey Armstrong | 6890fa9 | 2024-08-15 12:14:37 -0400 | [diff] [blame] | 827 | # query="$(join_by 'OR' "${suffix0[0]}")" |
Joey Armstrong | 9cbbf7f | 2024-08-14 17:05:18 -0400 | [diff] [blame] | 828 | error "Ambiguous query [argv needs: --and or --or]" |
| 829 | fi |
| 830 | |
| 831 | # banner "$(declare -p query)" |
| 832 | |
| 833 | |
| 834 | |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 835 | filter='' |
| 836 | gen_filter filter suffix0 |
| 837 | |
| 838 | if [[ ! -v urls_raw ]]; then |
| 839 | url='' |
| 840 | gen_url url filter |
| 841 | urls_filt+=("$url") |
| 842 | elif [ ${#urls_raw} -eq 0 ]; then |
| 843 | url='' |
| 844 | gen_url url filter |
| 845 | urls_filt+=("$url") |
| 846 | fi |
| 847 | |
| 848 | [[ -v debug ]] && [[ -v url ]] && echo "URL: $url" |
Joey Armstrong | e4ef06a | 2024-03-22 11:43:54 -0400 | [diff] [blame] | 849 | browser="${BROWSER:-firefox}" |
Joey Armstrong | 3134bfd | 2024-02-10 20:51:25 -0500 | [diff] [blame] | 850 | echo "$browser ${urls_filt[@]} ${urls_raw[@]}" |
| 851 | |
| 852 | if [[ ! -v dry_run ]]; then |
| 853 | "$browser" "${urls_filt[@]}" "${urls_raw[@]}" >/dev/null 2>/dev/null & |
| 854 | fi |
| 855 | |
| 856 | # [SEE ALSO] |
| 857 | # o https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-fields/ |
| 858 | |
| 859 | # [EOF] |