Compare commits

..
2 Commits
2 changed files with 13 additions and 4 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ import (
func (c *GitCommand) GetRemotes() ([]*Remote, error) {
// get remote branches
unescaped := "git for-each-ref --format='%(refname:strip=2)' refs/remotes"
unescaped := "git branch -r"
remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(unescaped)
if err != nil {
return nil, err
@@ -25,7 +25,7 @@ func (c *GitCommand) GetRemotes() ([]*Remote, error) {
for i, goGitRemote := range goGitRemotes {
remoteName := goGitRemote.Config().Name
re := regexp.MustCompile(fmt.Sprintf("%s\\/(.*)", remoteName))
re := regexp.MustCompile(fmt.Sprintf(`%s\/([\S]+)`, remoteName))
matches := re.FindAllStringSubmatch(remoteBranchesStr, -1)
branches := make([]*RemoteBranch, len(matches))
for j, match := range matches {
+11 -2
View File
@@ -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++