mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-28 09:08:41 +02:00
lenient sorting of tags on startup
This commit is contained in:
parent
7113ed73d4
commit
339e1b5dcf
@ -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++
|
||||
|
Loading…
Reference in New Issue
Block a user