Skip to content

Commit 674b62d

Browse files
authored
refactor(semantic): remove unneeded logic in parsing semver-like versions (#277)
1 parent f787d8d commit 674b62d

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

pkg/semantic/version-semver-like.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ func (v *SemverLikeVersion) fetchComponentsAndBuild(maxComponents int) (Componen
3838
func ParseSemverLikeVersion(line string, maxComponents int) SemverLikeVersion {
3939
v := parseSemverLike(line)
4040

41-
if maxComponents == -1 {
42-
return v
43-
}
44-
4541
components, build := v.fetchComponentsAndBuild(maxComponents)
4642

4743
return SemverLikeVersion{
@@ -60,7 +56,6 @@ func parseSemverLike(line string) SemverLikeVersion {
6056

6157
currentCom := ""
6258
foundBuild := false
63-
emptyComponent := false
6459

6560
leadingV := strings.HasPrefix(line, "v")
6661
line = strings.TrimPrefix(line, "v")
@@ -94,15 +89,11 @@ func parseSemverLike(line string) SemverLikeVersion {
9489

9590
components = append(components, v)
9691
currentCom = ""
97-
98-
emptyComponent = false
9992
}
10093

10194
// a component terminator means there might be another component
10295
// afterwards, so don't start parsing the build string just yet
10396
if c == '.' {
104-
emptyComponent = true
105-
10697
continue
10798
}
10899

@@ -118,19 +109,6 @@ func parseSemverLike(line string) SemverLikeVersion {
118109

119110
components = append(components, v)
120111
currentCom = ""
121-
emptyComponent = false
122-
}
123-
124-
// if we ended with an empty component section,
125-
// prefix the build string with a '.'
126-
if emptyComponent {
127-
currentCom = "." + currentCom
128-
}
129-
130-
// if we found no components, then the v wasn't actually leading
131-
if len(components) == 0 && leadingV {
132-
leadingV = false
133-
currentCom = "v" + currentCom
134112
}
135113

136114
return SemverLikeVersion{

0 commit comments

Comments
 (0)