From 00d33e34ac1d79610b53f4fa1759892a4e1bb0e90c01237e361ddd61a12ddc80 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 14 Mar 2024 16:14:00 +0300 Subject: [PATCH] !-tags --- list | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/list b/list index 4e7fa51..1641675 100755 --- a/list +++ b/list @@ -1,25 +1,44 @@ #!/usr/bin/env zsh +# Usage: list [[!]tag-expr ...] +# List all issues. If tag-expr is specified, then include issues only +# with at least one tag satisfying tag-expr. tag-expr is an expression +# tag is compared with. If "!" is prepended to tag-expr, then it excludes +# issues. root=$0:h:a . $root/lib.zsh.rc tagsOur=($@) -for issue (issues/**/created) { - issue=$issue:h - issue=${issue#issues/} - - tagsTheir=(`$root/tag-list $issue`) - tagsFound=0 +tagsSatisfied() { + local tagsTheir=($@) + for our ($tagsOur) { + [[ ${our[1]} = "!" ]] || continue + for their ($tagsTheir) { + if [[ $their =~ ${our[2,-1]} ]]; then + return 1 + fi + } + } for our ($tagsOur) { + [[ ${our[1]} != "!" ]] || continue + local satisfied=0 for their ($tagsTheir) { - if [[ $their =~ $our ]] ; then - tagsFound=$(( $tagsFound + 1 )) + if [[ $their =~ $our ]]; then + satisfied=1 break fi } + [[ $satisfied -eq 1 ]] || return 1 } - [[ $tagsFound -eq ${#tagsOur} ]] || continue +} + +for issue (issues/**/created) { + issue=$issue:h + issue=${issue#issues/} + + tagsTheir=(`$root/tag-list $issue`) + tagsSatisfied $tagsTheir || continue print -n `cat issues/$issue/created`\\t$issue\\t print $tagsTheir -- 2.44.0