Skip to content

Commit

Permalink
refactor(semantic): remove unneeded logic in parsing semver-like vers…
Browse files Browse the repository at this point in the history
…ions (#277)
  • Loading branch information
G-Rath authored Oct 31, 2024
1 parent f787d8d commit 674b62d
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions pkg/semantic/version-semver-like.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ func (v *SemverLikeVersion) fetchComponentsAndBuild(maxComponents int) (Componen
func ParseSemverLikeVersion(line string, maxComponents int) SemverLikeVersion {
v := parseSemverLike(line)

if maxComponents == -1 {
return v
}

components, build := v.fetchComponentsAndBuild(maxComponents)

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

currentCom := ""
foundBuild := false
emptyComponent := false

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

components = append(components, v)
currentCom = ""

emptyComponent = false
}

// a component terminator means there might be another component
// afterwards, so don't start parsing the build string just yet
if c == '.' {
emptyComponent = true

continue
}

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

components = append(components, v)
currentCom = ""
emptyComponent = false
}

// if we ended with an empty component section,
// prefix the build string with a '.'
if emptyComponent {
currentCom = "." + currentCom
}

// if we found no components, then the v wasn't actually leading
if len(components) == 0 && leadingV {
leadingV = false
currentCom = "v" + currentCom
}

return SemverLikeVersion{
Expand Down

0 comments on commit 674b62d

Please sign in to comment.