Skip to content

Commit

Permalink
Merge pull request #1112 from rsteube/git-stash-style
Browse files Browse the repository at this point in the history
git: fix stash style
  • Loading branch information
rsteube authored May 9, 2022
2 parents c3f3da8 + 46c129c commit a9554ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/actions/tools/git/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func ActionRefs(refOption RefOption) carapace.Action {
if refOption.Stashes {
return carapace.Batch(
carapace.ActionStyledValuesDescribed(vals...),
ActionStashes().Style(styles.Git.Stash),
ActionStashes(),
).ToA()
}
return carapace.ActionStyledValuesDescribed(vals...)
Expand Down
10 changes: 5 additions & 5 deletions pkg/actions/tools/git/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/styles"
)

// ActionStashes completes stash names
Expand All @@ -13,14 +14,13 @@ func ActionStashes() carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return carapace.ActionExecCommand("git", "stash", "list")(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")
vals := make([]string, (len(lines)-1)*2)
vals := make([]string, 0)

for index, line := range lines[:len(lines)-1] {
for _, line := range lines[:len(lines)-1] {
splitted := strings.SplitN(line, ": ", 2)
vals[index*2] = splitted[0]
vals[(index*2)+1] = splitted[1]
vals = append(vals, splitted[0], splitted[1])
}
return carapace.ActionValuesDescribed(vals...)
return carapace.ActionValuesDescribed(vals...).Style(styles.Git.Stash)
})
})
}

0 comments on commit a9554ed

Please sign in to comment.