Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: vpython/spec/match.go

Issue 2927573002: [vpython] Fix PEP425 naming. (Closed)
Patch Set: rebase and update Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « vpython/cipd/pep425_test.go ('k') | vpython/spec/match_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package spec 5 package spec
6 6
7 import ( 7 import (
8 "github.com/luci/luci-go/vpython/api/vpython" 8 "github.com/luci/luci-go/vpython/api/vpython"
9 ) 9 )
10 10
11 // PackageMatches returns true if any of the match qualifiers in the supplied 11 // PackageMatches returns true if any of the match qualifiers in the supplied
12 // package match at least one of the supplied PEP425 tags. 12 // package match at least one of the supplied PEP425 tags.
13 // 13 //
14 // As a special case, if the package doesn't specify any match tags, it will 14 // As a special case, if the package doesn't specify any match tags, it will
15 // always match regardless of the supplied PEP425 tags. 15 // always match regardless of the supplied PEP425 tags.
16 // 16 //
17 // See PEP425Matches for more information. 17 // See PEP425Matches for more information.
18 func PackageMatches(pkg *vpython.Spec_Package, tags []*vpython.Pep425Tag) bool { 18 func PackageMatches(pkg *vpython.Spec_Package, tags []*vpython.PEP425Tag) bool {
19 if len(pkg.MatchTag) == 0 { 19 if len(pkg.MatchTag) == 0 {
20 return true 20 return true
21 } 21 }
22 22
23 for _, matchTag := range pkg.MatchTag { 23 for _, matchTag := range pkg.MatchTag {
24 if PEP425Matches(matchTag, tags) { 24 if PEP425Matches(matchTag, tags) {
25 return true 25 return true
26 } 26 }
27 } 27 }
28 return false 28 return false
29 } 29 }
30 30
31 // PEP425Matches returns true if match matches at least one of the tags in tags. 31 // PEP425Matches returns true if match matches at least one of the tags in tags.
32 // 32 //
33 // A match is determined if the non-zero fields in match equal the equivalent 33 // A match is determined if the non-zero fields in match equal the equivalent
34 // fields in a tag. 34 // fields in a tag.
35 func PEP425Matches(match *vpython.Pep425Tag, tags []*vpython.Pep425Tag) bool { 35 func PEP425Matches(match *vpython.PEP425Tag, tags []*vpython.PEP425Tag) bool {
36 // Special case: empty match matches nothing. 36 // Special case: empty match matches nothing.
37 if match.IsZero() { 37 if match.IsZero() {
38 return false 38 return false
39 } 39 }
40 40
41 for _, tag := range tags { 41 for _, tag := range tags {
42 » » if v := match.Version; v != "" && tag.Version != v { 42 » » if v := match.Python; v != "" && tag.Python != v {
43 continue 43 continue
44 } 44 }
45 if v := match.Abi; v != "" && tag.Abi != v { 45 if v := match.Abi; v != "" && tag.Abi != v {
46 continue 46 continue
47 } 47 }
48 » » if v := match.Arch; v != "" && tag.Arch != v { 48 » » if v := match.Platform; v != "" && tag.Platform != v {
49 continue 49 continue
50 } 50 }
51 return true 51 return true
52 } 52 }
53 53
54 return false 54 return false
55 } 55 }
OLDNEW
« no previous file with comments | « vpython/cipd/pep425_test.go ('k') | vpython/spec/match_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698