cue/load: remove unused code
Change-Id: I29d80f4c9be10577ff39fa156f5dbb37cb5ce78b
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9681
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/cue/load/match.go b/cue/load/match.go
index 4d3378c..4ff21b4 100644
--- a/cue/load/match.go
+++ b/cue/load/match.go
@@ -18,7 +18,6 @@
"io/ioutil"
"path/filepath"
"strings"
- "unicode"
"cuelang.org/go/cue/build"
"cuelang.org/go/cue/errors"
@@ -82,56 +81,3 @@
match = true
return
}
-
-// doMatch reports whether the name is one of:
-//
-// tag (if tag is listed in cfg.Build.BuildTags or cfg.Build.ReleaseTags)
-// !tag (if tag is not listed in cfg.Build.BuildTags or cfg.Build.ReleaseTags)
-// a comma-separated list of any of these
-//
-func doMatch(cfg *Config, name string, allTags map[string]bool) bool {
- if name == "" {
- if allTags != nil {
- allTags[name] = true
- }
- return false
- }
- if i := strings.Index(name, ","); i >= 0 {
- // comma-separated list
- ok1 := doMatch(cfg, name[:i], allTags)
- ok2 := doMatch(cfg, name[i+1:], allTags)
- return ok1 && ok2
- }
- if strings.HasPrefix(name, "!!") { // bad syntax, reject always
- return false
- }
- if strings.HasPrefix(name, "!") { // negation
- return len(name) > 1 && !doMatch(cfg, name[1:], allTags)
- }
-
- if allTags != nil {
- allTags[name] = true
- }
-
- // Tags must be letters, digits, underscores or dots.
- // Unlike in CUE identifiers, all digits are fine (e.g., "386").
- for _, c := range name {
- if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' {
- return false
- }
- }
-
- // other tags
- for _, tag := range cfg.BuildTags {
- if tag == name {
- return true
- }
- }
- for _, tag := range cfg.releaseTags {
- if tag == name {
- return true
- }
- }
-
- return false
-}
diff --git a/cue/load/match_test.go b/cue/load/match_test.go
deleted file mode 100644
index 0e7d69e..0000000
--- a/cue/load/match_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018 The CUE Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package load
-
-import (
- "reflect"
- "testing"
-)
-
-func TestMatch(t *testing.T) {
- c := &Config{}
- what := "default"
- matchFn := func(tag string, want map[string]bool) {
- t.Helper()
- m := make(map[string]bool)
- if !doMatch(c, tag, m) {
- t.Errorf("%s context should match %s, does not", what, tag)
- }
- if !reflect.DeepEqual(m, want) {
- t.Errorf("%s tags = %v, want %v", tag, m, want)
- }
- }
- noMatch := func(tag string, want map[string]bool) {
- m := make(map[string]bool)
- if doMatch(c, tag, m) {
- t.Errorf("%s context should NOT match %s, does", what, tag)
- }
- if !reflect.DeepEqual(m, want) {
- t.Errorf("%s tags = %v, want %v", tag, m, want)
- }
- }
-
- c.BuildTags = []string{"foo"}
- matchFn("foo", map[string]bool{"foo": true})
- noMatch("!foo", map[string]bool{"foo": true})
- matchFn("foo,!bar", map[string]bool{"foo": true, "bar": true})
- noMatch("!", map[string]bool{})
-}