1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

move stash panel

This commit is contained in:
Jesse Duffield
2020-09-29 18:46:45 +10:00
parent 8d2af5cc61
commit 91f0b0e28f
7 changed files with 21 additions and 20 deletions

View File

@ -200,10 +200,10 @@ func findDotGitDir(stat func(string) (os.FileInfo, error), readFile func(filenam
return strings.TrimSpace(strings.TrimPrefix(fileContent, "gitdir: ")), nil
}
func (c *GitCommand) getUnfilteredStashEntries() []*StashEntry {
func (c *GitCommand) getUnfilteredStashEntries() []*models.StashEntry {
unescaped := "git stash list --pretty='%gs'"
rawString, _ := c.OSCommand.RunCommandWithOutput(unescaped)
stashEntries := []*StashEntry{}
stashEntries := []*models.StashEntry{}
for i, line := range utils.SplitLines(rawString) {
stashEntries = append(stashEntries, stashEntryFromLine(line, i))
}
@ -211,7 +211,7 @@ func (c *GitCommand) getUnfilteredStashEntries() []*StashEntry {
}
// GetStashEntries stash entries
func (c *GitCommand) GetStashEntries(filterPath string) []*StashEntry {
func (c *GitCommand) GetStashEntries(filterPath string) []*models.StashEntry {
if filterPath == "" {
return c.getUnfilteredStashEntries()
}
@ -221,8 +221,8 @@ func (c *GitCommand) GetStashEntries(filterPath string) []*StashEntry {
if err != nil {
return c.getUnfilteredStashEntries()
}
stashEntries := []*StashEntry{}
var currentStashEntry *StashEntry
stashEntries := []*models.StashEntry{}
var currentStashEntry *models.StashEntry
lines := utils.SplitLines(rawString)
isAStash := func(line string) bool { return strings.HasPrefix(line, "stash@{") }
re := regexp.MustCompile(`stash@\{(\d+)\}`)
@ -249,8 +249,8 @@ outer:
return stashEntries
}
func stashEntryFromLine(line string, index int) *StashEntry {
return &StashEntry{
func stashEntryFromLine(line string, index int) *models.StashEntry {
return &models.StashEntry{
Name: line,
Index: index,
}

View File

@ -13,6 +13,7 @@ import (
"github.com/go-errors/errors"
gogit "github.com/go-git/go-git/v5"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/test"
"github.com/stretchr/testify/assert"
)
@ -260,7 +261,7 @@ func TestGitCommandGetStashEntries(t *testing.T) {
type scenario struct {
testName string
command func(string, ...string) *exec.Cmd
test func([]*StashEntry)
test func([]*models.StashEntry)
}
scenarios := []scenario{
@ -269,7 +270,7 @@ func TestGitCommandGetStashEntries(t *testing.T) {
func(string, ...string) *exec.Cmd {
return exec.Command("echo")
},
func(entries []*StashEntry) {
func(entries []*models.StashEntry) {
assert.Len(t, entries, 0)
},
},
@ -278,8 +279,8 @@ func TestGitCommandGetStashEntries(t *testing.T) {
func(string, ...string) *exec.Cmd {
return exec.Command("echo", "WIP on add-pkg-commands-test: 55c6af2 increase parallel build\nWIP on master: bb86a3f update github template")
},
func(entries []*StashEntry) {
expected := []*StashEntry{
func(entries []*models.StashEntry) {
expected := []*models.StashEntry{
{
0,
"WIP on add-pkg-commands-test: 55c6af2 increase parallel build",

View File

@ -1,21 +0,0 @@
package commands
import "fmt"
// StashEntry : A git stash entry
type StashEntry struct {
Index int
Name string
}
func (s *StashEntry) RefName() string {
return fmt.Sprintf("stash@{%d}", s.Index)
}
func (s *StashEntry) ID() string {
return s.RefName()
}
func (s *StashEntry) Description() string {
return s.RefName() + ": " + s.Name
}