diff --git a/pkg/commands/loading_tags.go b/pkg/commands/loading_tags.go index ae2f0ba17..95ebb450c 100644 --- a/pkg/commands/loading_tags.go +++ b/pkg/commands/loading_tags.go @@ -3,6 +3,7 @@ package commands import ( "regexp" "sort" + "strconv" "strings" "github.com/jesseduffield/lazygit/pkg/utils" @@ -10,6 +11,14 @@ import ( const semverRegex = `v?((\d+\.?)+)([^\d]?.*)` +func convertToInt(s string) int { + i, err := strconv.Atoi(s) + if err != nil { + return 0 + } + return i +} + func (c *GitCommand) GetTags() ([]*Tag, error) { // get remote branches remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(`git tag --list`) @@ -59,10 +68,10 @@ func (c *GitCommand) GetTags() ([]*Tag, error) { if len(numbersB) == k { return false } - if mustConvertToInt(numbersA[k]) < mustConvertToInt(numbersB[k]) { + if convertToInt(numbersA[k]) < convertToInt(numbersB[k]) { return true } - if mustConvertToInt(numbersA[k]) > mustConvertToInt(numbersB[k]) { + if convertToInt(numbersA[k]) > convertToInt(numbersB[k]) { return false } k++