Skip to content

Commit 92d095f

Browse files
committed
add per expression negation
1 parent 2cf1617 commit 92d095f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"os"
88
"regexp"
9+
"strings"
910

1011
"github.com/moepi/nexus-cli/registry"
1112
"github.com/urfave/cli"
@@ -183,11 +184,16 @@ func filterTagsByRegex(tags []string, expressions []string, invert bool) ([]stri
183184
}
184185
for _, tag := range tags {
185186
for _, expression := range expressions {
187+
var expressionInvert = invert
188+
if strings.HasPrefix(expression, "!") {
189+
expressionInvert = !invert
190+
expression = strings.Trim(expression, "!")
191+
}
186192
retVal, err := regexp.MatchString(expression, tag)
187193
if err != nil {
188194
return retTags, err
189195
}
190-
if retVal == !invert {
196+
if retVal == !expressionInvert {
191197
retTags = append(retTags, tag)
192198
// tag must match any expression, so continue with next tag on match
193199
break

0 commit comments

Comments
 (0)