mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +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()
|
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()
|
rawString, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return self.getUnfilteredStashEntries()
|
return self.getUnfilteredStashEntries()
|
||||||
@@ -66,7 +66,7 @@ outer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *StashLoader) getUnfilteredStashEntries() []*models.StashEntry {
|
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()
|
rawString, _ := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||||
return lo.Map(utils.SplitNul(rawString), func(line string, index int) *models.StashEntry {
|
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,
|
Index: index,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hash, line, ok := strings.Cut(line, "|")
|
||||||
|
if !ok {
|
||||||
|
return model
|
||||||
|
}
|
||||||
|
model.Hash = hash
|
||||||
|
|
||||||
tstr, msg, ok := strings.Cut(line, "|")
|
tstr, msg, ok := strings.Cut(line, "|")
|
||||||
if !ok {
|
if !ok {
|
||||||
return model
|
return model
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ func TestGetStashEntries(t *testing.T) {
|
|||||||
"No stash entries found",
|
"No stash entries found",
|
||||||
"",
|
"",
|
||||||
oscommands.NewFakeRunner(t).
|
oscommands.NewFakeRunner(t).
|
||||||
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"}, "", nil),
|
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%H|%ct|%gs"}, "", nil),
|
||||||
[]*models.StashEntry{},
|
[]*models.StashEntry{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Several stash entries found",
|
"Several stash entries found",
|
||||||
"",
|
"",
|
||||||
oscommands.NewFakeRunner(t).
|
oscommands.NewFakeRunner(t).
|
||||||
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%ct|%gs"},
|
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%H|%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",
|
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,
|
hoursAgo,
|
||||||
daysAgo,
|
daysAgo,
|
||||||
), nil),
|
), nil),
|
||||||
@@ -44,11 +44,13 @@ func TestGetStashEntries(t *testing.T) {
|
|||||||
Index: 0,
|
Index: 0,
|
||||||
Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
|
Name: "WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
|
||||||
Recency: "3h",
|
Recency: "3h",
|
||||||
|
Hash: "fa1afe1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Index: 1,
|
Index: 1,
|
||||||
Name: "WIP on master: bb86a3f update github template",
|
Name: "WIP on master: bb86a3f update github template",
|
||||||
Recency: "3d",
|
Recency: "3d",
|
||||||
|
Hash: "deadbeef",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ type StashEntry struct {
|
|||||||
Index int
|
Index int
|
||||||
Recency string
|
Recency string
|
||||||
Name string
|
Name string
|
||||||
|
Hash string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StashEntry) FullRefName() string {
|
func (s *StashEntry) FullRefName() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user