Skip to content

Commit

Permalink
switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
adlotsof committed Sep 20, 2023
1 parent 07a1cc5 commit bf96cca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
1 change: 1 addition & 0 deletions core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
MinorLevel = "minor"
PatchLevel = "patch"
NoneLevel = "none"
EmptyLevel = ""
)

var ConfigPaths []string = []string{
Expand Down
45 changes: 21 additions & 24 deletions core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,32 +128,29 @@ func HighestAutoLevel(config *Config, allChanges []Change) (highestLevel string,
continue
}

if kc.AutoLevel == "" {
return "", ErrMissingAutoLevel
}

if kc.AutoLevel == NoneLevel {
continue
}

// bump to patch if we have a patch level
if kc.AutoLevel == PatchLevel && highestLevel == "" {
highestLevel = PatchLevel
err = nil

switch kc.AutoLevel {
case NoneLevel:
continue
}

// major is the highest one, so we can just return it
if kc.AutoLevel == MajorLevel {
case MajorLevel:
// major is the highest one, so we can just return it
return MajorLevel, nil
}

// bump to minor if we have a minor level
if kc.AutoLevel == MinorLevel &&
(highestLevel == PatchLevel || highestLevel == "") {
highestLevel = MinorLevel
err = nil
case PatchLevel:
if highestLevel == "" {
highestLevel = PatchLevel
err = nil

continue
}
case MinorLevel:
// bump to minor if we have a minor level
if highestLevel == PatchLevel || highestLevel == "" {
highestLevel = MinorLevel
err = nil

continue
}
case EmptyLevel:
return "", ErrMissingAutoLevel
}
}
}
Expand Down

0 comments on commit bf96cca

Please sign in to comment.