mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-09-16 09:16:26 +02:00
Add hash field to models.StashEntry
This commit is contained in:
@@ -32,7 +32,7 @@ func (self *StashLoader) GetStashEntries(filterPath string) []*models.StashEntry
|
||||
return self.getUnfilteredStashEntries()
|
||||
}
|
||||
|
||||
cmdArgs := NewGitCmd("stash").Arg("list", "--name-only", "--pretty=%gd:%ct|%gs").ToArgv()
|
||||
cmdArgs := NewGitCmd("stash").Arg("list", "--name-only", "--pretty=%gd:%H|%ct|%gs").ToArgv()
|
||||
rawString, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||
if err != nil {
|
||||
return self.getUnfilteredStashEntries()
|
||||
@@ -66,7 +66,7 @@ outer:
|
||||
}
|
||||
|
||||
func (self *StashLoader) getUnfilteredStashEntries() []*models.StashEntry {
|
||||
cmdArgs := NewGitCmd("stash").Arg("list", "-z", "--pretty=%ct|%gs").ToArgv()
|
||||
cmdArgs := NewGitCmd("stash").Arg("list", "-z", "--pretty=%H|%ct|%gs").ToArgv()
|
||||
|
||||
rawString, _ := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||
return lo.Map(utils.SplitNul(rawString), func(line string, index int) *models.StashEntry {
|
||||
@@ -80,6 +80,12 @@ func stashEntryFromLine(line string, index int) *models.StashEntry {
|
||||
Index: index,
|
||||
}
|
||||
|
||||
hash, line, ok := strings.Cut(line, "|")
|
||||
if !ok {
|
||||
return model
|
||||
}
|
||||
model.Hash = hash
|
||||
|
||||
tstr, msg, ok := strings.Cut(line, "|")
|
||||
if !ok {
|
||||
return model
|
||||
|
@@ -27,15 +27,15 @@ func TestGetStashEntries(t *testing.T) {
|
||||
"No stash entries found",
|
||||
"",
|
||||
oscommands.NewFakeRunner(t).
|
||||
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"}, "", nil),
|
||||
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%H|%ct|%gs"}, "", nil),
|
||||
[]*models.StashEntry{},
|
||||
},
|
||||
{
|
||||
"Several stash entries found",
|
||||
"",
|
||||
oscommands.NewFakeRunner(t).
|
||||
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"},
|
||||
fmt.Sprintf("%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00%d|WIP on master: bb86a3f update github template\x00",
|
||||
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%H|%ct|%gs"},
|
||||
fmt.Sprintf("fa1afe1|%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00deadbeef|%d|WIP on master: bb86a3f update github template\x00",
|
||||
hoursAgo,
|
||||
daysAgo,
|
||||
), nil),
|
||||
@@ -44,11 +44,13 @@ func TestGetStashEntries(t *testing.T) {
|
||||
Index: 0,
|
||||
Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
|
||||
Recency: "3h",
|
||||
Hash: "fa1afe1",
|
||||
},
|
||||
{
|
||||
Index: 1,
|
||||
Name: "WIP on master: bb86a3f update github template",
|
||||
Recency: "3d",
|
||||
Hash: "deadbeef",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -7,6 +7,7 @@ type StashEntry struct {
|
||||
Index int
|
||||
Recency string
|
||||
Name string
|
||||
Hash string
|
||||
}
|
||||
|
||||
func (s *StashEntry) FullRefName() string {
|
||||
|
Reference in New Issue
Block a user