mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-17 01:42:45 +02:00
lenient sorting of tags on startup
This commit is contained in:
@ -3,6 +3,7 @@ package commands
|
|||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
@ -10,6 +11,14 @@ import (
|
|||||||
|
|
||||||
const semverRegex = `v?((\d+\.?)+)([^\d]?.*)`
|
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) {
|
func (c *GitCommand) GetTags() ([]*Tag, error) {
|
||||||
// get remote branches
|
// get remote branches
|
||||||
remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(`git tag --list`)
|
remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(`git tag --list`)
|
||||||
@ -59,10 +68,10 @@ func (c *GitCommand) GetTags() ([]*Tag, error) {
|
|||||||
if len(numbersB) == k {
|
if len(numbersB) == k {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if mustConvertToInt(numbersA[k]) < mustConvertToInt(numbersB[k]) {
|
if convertToInt(numbersA[k]) < convertToInt(numbersB[k]) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if mustConvertToInt(numbersA[k]) > mustConvertToInt(numbersB[k]) {
|
if convertToInt(numbersA[k]) > convertToInt(numbersB[k]) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
k++
|
k++
|
||||||
|
Reference in New Issue
Block a user