mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Make stash loading work in filtering mode
This broke with the introduction of the age in the stashes list in bc330b8ff3
(which was included in 0.41, so 12 minor versions ago).
This makes it work again when filtering by file, but it still doesn't work when
filtering by folder (and never has). We'll fix that next.
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=%ct|%gs").ToArgv()
|
cmdArgs := NewGitCmd("stash").Arg("list", "--name-only", "--pretty=%gd:%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()
|
||||||
@ -41,19 +41,19 @@ func (self *StashLoader) GetStashEntries(filterPath string) []*models.StashEntry
|
|||||||
var currentStashEntry *models.StashEntry
|
var currentStashEntry *models.StashEntry
|
||||||
lines := utils.SplitLines(rawString)
|
lines := utils.SplitLines(rawString)
|
||||||
isAStash := func(line string) bool { return strings.HasPrefix(line, "stash@{") }
|
isAStash := func(line string) bool { return strings.HasPrefix(line, "stash@{") }
|
||||||
re := regexp.MustCompile(`stash@\{(\d+)\}`)
|
re := regexp.MustCompile(`^stash@\{(\d+)\}:(.*)$`)
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
for i := 0; i < len(lines); i++ {
|
for i := 0; i < len(lines); i++ {
|
||||||
if !isAStash(lines[i]) {
|
match := re.FindStringSubmatch(lines[i])
|
||||||
|
if match == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
match := re.FindStringSubmatch(lines[i])
|
|
||||||
idx, err := strconv.Atoi(match[1])
|
idx, err := strconv.Atoi(match[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return self.getUnfilteredStashEntries()
|
return self.getUnfilteredStashEntries()
|
||||||
}
|
}
|
||||||
currentStashEntry = stashEntryFromLine(lines[i], idx)
|
currentStashEntry = stashEntryFromLine(match[2], idx)
|
||||||
for i+1 < len(lines) && !isAStash(lines[i+1]) {
|
for i+1 < len(lines) && !isAStash(lines[i+1]) {
|
||||||
i++
|
i++
|
||||||
if lines[i] == filterPath {
|
if lines[i] == filterPath {
|
||||||
|
@ -44,13 +44,10 @@ var FilterByPath = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
filterBy("file1")
|
filterBy("file1")
|
||||||
|
|
||||||
t.Views().Stash().
|
t.Views().Stash().
|
||||||
/* EXPECTED:
|
|
||||||
Lines(
|
Lines(
|
||||||
Contains("file1 again"),
|
Contains("file1 again"),
|
||||||
Contains("file1"),
|
Contains("file1"),
|
||||||
)
|
)
|
||||||
ACTUAL: */
|
|
||||||
IsEmpty()
|
|
||||||
|
|
||||||
t.GlobalPress(keys.Universal.Return)
|
t.GlobalPress(keys.Universal.Return)
|
||||||
filterBy("subdir")
|
filterBy("subdir")
|
||||||
|
Reference in New Issue
Block a user