mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
fix: fix stash with empty message
This commit is contained in:
parent
fc0b14edef
commit
a4239c7a37
@ -65,8 +65,8 @@ outer:
|
||||
}
|
||||
|
||||
func (self *StashLoader) getUnfilteredStashEntries() []*models.StashEntry {
|
||||
rawString, _ := self.cmd.New("git stash list --pretty='%gs'").DontLog().RunWithOutput()
|
||||
return slices.MapWithIndex(utils.SplitLines(rawString), func(line string, index int) *models.StashEntry {
|
||||
rawString, _ := self.cmd.New("git stash list -z --pretty='%gs'").DontLog().RunWithOutput()
|
||||
return slices.MapWithIndex(utils.SplitNul(rawString), func(line string, index int) *models.StashEntry {
|
||||
return self.stashEntryFromLine(line, index)
|
||||
})
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func TestGetStashEntries(t *testing.T) {
|
||||
"No stash entries found",
|
||||
"",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(`git stash list --pretty='%gs'`, "", nil),
|
||||
Expect(`git stash list -z --pretty='%gs'`, "", nil),
|
||||
[]*models.StashEntry{},
|
||||
},
|
||||
{
|
||||
@ -30,8 +30,8 @@ func TestGetStashEntries(t *testing.T) {
|
||||
"",
|
||||
oscommands.NewFakeRunner(t).
|
||||
Expect(
|
||||
`git stash list --pretty='%gs'`,
|
||||
"WIP on add-pkg-commands-test: 55c6af2 increase parallel build\nWIP on master: bb86a3f update github template",
|
||||
`git stash list -z --pretty='%gs'`,
|
||||
"WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00WIP on master: bb86a3f update github template\x00",
|
||||
nil,
|
||||
),
|
||||
[]*models.StashEntry{
|
||||
|
@ -17,6 +17,14 @@ func SplitLines(multilineString string) []string {
|
||||
return lines
|
||||
}
|
||||
|
||||
func SplitNul(str string) []string {
|
||||
if str == "" {
|
||||
return make([]string, 0)
|
||||
}
|
||||
str = strings.TrimSuffix(str, "\x00")
|
||||
return strings.Split(str, "\x00")
|
||||
}
|
||||
|
||||
// NormalizeLinefeeds - Removes all Windows and Mac style line feeds
|
||||
func NormalizeLinefeeds(str string) string {
|
||||
str = strings.Replace(str, "\r\n", "\n", -1)
|
||||
|
@ -36,6 +36,37 @@ func TestSplitLines(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitNul(t *testing.T) {
|
||||
type scenario struct {
|
||||
multilineString string
|
||||
expected []string
|
||||
}
|
||||
|
||||
scenarios := []scenario{
|
||||
{
|
||||
"",
|
||||
[]string{},
|
||||
},
|
||||
{
|
||||
"\x00",
|
||||
[]string{
|
||||
"",
|
||||
},
|
||||
},
|
||||
{
|
||||
"hello world !\x00hello universe !\x00",
|
||||
[]string{
|
||||
"hello world !",
|
||||
"hello universe !",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
assert.EqualValues(t, s.expected, SplitNul(s.multilineString))
|
||||
}
|
||||
}
|
||||
|
||||
// TestNormalizeLinefeeds is a function.
|
||||
func TestNormalizeLinefeeds(t *testing.T) {
|
||||
type scenario struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user