mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	update github.com/mcuadros/go-version to v0.0.0-20190308113854-92cdf37c5b75 (#6815)
This commit is contained in:
		 Lunny Xiao
					Lunny Xiao
				
			
				
					committed by
					
						 techknowlogick
						techknowlogick
					
				
			
			
				
	
			
			
			 techknowlogick
						techknowlogick
					
				
			
						parent
						
							eb8632b20b
						
					
				
				
					commit
					5be1780045
				
			
							
								
								
									
										22
									
								
								vendor/github.com/mcuadros/go-version/compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/mcuadros/go-version/compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,16 +11,18 @@ var regexpDotBeforeDigit = regexp.MustCompile(`([^.\d]+)`) | ||||
| var regexpMultipleDots = regexp.MustCompile(`\.{2,}`) | ||||
|  | ||||
| var specialForms = map[string]int{ | ||||
| 	"dev":   -6, | ||||
| 	"alpha": -5, | ||||
| 	"a":     -5, | ||||
| 	"beta":  -4, | ||||
| 	"b":     -4, | ||||
| 	"RC":    -3, | ||||
| 	"rc":    -3, | ||||
| 	"#":     -2, | ||||
| 	"p":     1, | ||||
| 	"pl":    1, | ||||
| 	"SNAPSHOT": -7, | ||||
| 	"snapshot": -7, | ||||
| 	"dev":      -6, | ||||
| 	"alpha":    -5, | ||||
| 	"a":        -5, | ||||
| 	"beta":     -4, | ||||
| 	"b":        -4, | ||||
| 	"RC":       -3, | ||||
| 	"rc":       -3, | ||||
| 	"#":        -2, | ||||
| 	"p":        1, | ||||
| 	"pl":       1, | ||||
| } | ||||
|  | ||||
| var unknownForm int = -7 | ||||
|   | ||||
							
								
								
									
										33
									
								
								vendor/github.com/mcuadros/go-version/group.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										33
									
								
								vendor/github.com/mcuadros/go-version/group.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,6 +4,7 @@ import ( | ||||
| 	"regexp" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| ) | ||||
|  | ||||
| type ConstraintGroup struct { | ||||
| @@ -241,8 +242,38 @@ func (self *ConstraintGroup) parseConstraint(constraint string) []*Constraint { | ||||
| 	return []*Constraint{{constraint, stabilityModifier}} | ||||
| } | ||||
|  | ||||
| // PCRegMap : PreCompiled Regex Map | ||||
| type PCRegMap struct { | ||||
| 	sync.RWMutex | ||||
| 	m map[string]*regexp.Regexp | ||||
| } | ||||
|  | ||||
| // MustCompile : to replace regexp.MustCompile in RegFind. | ||||
| func (p *PCRegMap) MustCompile(pattern string) *regexp.Regexp { | ||||
| 	p.RLock() | ||||
| 	ret, exist := p.m[pattern] | ||||
| 	p.RUnlock() | ||||
| 	if exist { | ||||
| 		return ret | ||||
| 	} | ||||
| 	ret = regexp.MustCompile(pattern) | ||||
| 	p.Lock() | ||||
| 	p.m[pattern] = ret | ||||
| 	p.Unlock() | ||||
| 	return ret | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	regexpCache *PCRegMap | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	regexpCache = new(PCRegMap) | ||||
| 	regexpCache.m = make(map[string]*regexp.Regexp) | ||||
| } | ||||
|  | ||||
| func RegFind(pattern, subject string) []string { | ||||
| 	reg := regexp.MustCompile(pattern) | ||||
| 	reg := regexpCache.MustCompile(pattern) | ||||
| 	matched := reg.FindAllStringSubmatch(subject, -1) | ||||
|  | ||||
| 	if matched != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user