diff options
Diffstat (limited to 'pkg/commands/loaders/tags.go')
-rw-r--r-- | pkg/commands/loaders/tags.go | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/pkg/commands/loaders/tags.go b/pkg/commands/loaders/tags.go index 45b08a002..8e5063c34 100644 --- a/pkg/commands/loaders/tags.go +++ b/pkg/commands/loaders/tags.go @@ -1,8 +1,7 @@ package loaders import ( - "strings" - + "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/common" @@ -27,25 +26,18 @@ func NewTagLoader( func (self *TagLoader) GetTags() ([]*models.Tag, error) { // get remote branches, sorted by creation date (descending) // see: https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---sortltkeygt - remoteBranchesStr, err := self.cmd.New(`git tag --list --sort=-creatordate`).DontLog().RunWithOutput() + tagsOutput, err := self.cmd.New(`git tag --list --sort=-creatordate`).DontLog().RunWithOutput() if err != nil { return nil, err } - content := utils.TrimTrailingNewline(remoteBranchesStr) - if content == "" { - return nil, nil - } - - split := strings.Split(content, "\n") + split := utils.SplitLines(tagsOutput) - // first step is to get our remotes from go-git - tags := make([]*models.Tag, len(split)) - for i, tagName := range split { - tags[i] = &models.Tag{ + tags := slices.Map(split, func(tagName string) *models.Tag { + return &models.Tag{ Name: tagName, } - } + }) return tags, nil } |