]> Sergey Matveev's repositories - schwabrak.git/blob - list
Explicit empty line separator
[schwabrak.git] / list
1 #!/usr/bin/env zsh
2 # Usage: list [[!]tag-expr ...]
3 # List all issues. If tag-expr is specified, then include issues only
4 # with at least one tag satisfying tag-expr. tag-expr is an expression
5 # tag is compared with. If "!" is prepended to tag-expr, then it excludes
6 # issues.
7
8 root=$0:h:a
9 . $root/lib.zsh.rc
10
11 tagsOur=($@)
12
13 tagsSatisfied() {
14     local tagsTheir=($@)
15     for our ($tagsOur) {
16         [[ ${our[1]} = "!" ]] || continue
17         for their ($tagsTheir) {
18             if [[ $their =~ ${our[2,-1]} ]]; then
19                 return 1
20             fi
21         }
22     }
23     for our ($tagsOur) {
24         [[ ${our[1]} != "!" ]] || continue
25         local satisfied=0
26         for their ($tagsTheir) {
27             if [[ $their =~ $our ]]; then
28                 satisfied=1
29                 break
30             fi
31         }
32         [[ $satisfied -eq 1 ]] || return 1
33     }
34 }
35
36 for issue (issues/**/created) {
37     issue=$issue:h
38     issue=${issue#issues/}
39
40     tagsTheir=(`$root/tag-list $issue`)
41     tagsSatisfied $tagsTheir || continue
42
43     print -n `cat issues/$issue/created`\\t$issue\\t
44     print $tagsTheir
45 } | sort -r |
46 colourise green:"^.{19}" cyan:" [^      ]*$" red:"      .*\/"