summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/commands/git.go14
-rw-r--r--pkg/commands/git_test.go9
-rw-r--r--pkg/gui/custom_commands.go2
-rw-r--r--pkg/gui/gui.go4
-rw-r--r--pkg/gui/presentation/stash_entries.go6
-rw-r--r--pkg/gui/stash_panel.go4
-rw-r--r--pkg/models/stash_entry.go (renamed from pkg/commands/stash_entry.go)2
7 files changed, 21 insertions, 20 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index e7fcbd634..2d75330e6 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -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,
}
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index e22750425..17f31e9cd 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -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",
diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go
index 67f90b36c..9d2483587 100644
--- a/pkg/gui/custom_commands.go
+++ b/pkg/gui/custom_commands.go
@@ -22,7 +22,7 @@ type CustomCommandObjects struct {
SelectedRemoteBranch *models.RemoteBranch
SelectedRemote *models.Remote
SelectedTag *models.Tag
- SelectedStashEntry *commands.StashEntry
+ SelectedStashEntry *models.StashEntry
SelectedCommitFile *commands.CommitFile
CheckedOutBranch *models.Branch
PromptResponses []string
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index cdfa5d8b6..02bb27a65 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -276,7 +276,7 @@ type guiState struct {
SubmoduleConfigs []*models.SubmoduleConfig
Branches []*models.Branch
Commits []*models.Commit
- StashEntries []*commands.StashEntry
+ StashEntries []*models.StashEntry
CommitFiles []*commands.CommitFile
// FilteredReflogCommits are the ones that appear in the reflog panel.
// when in filtering mode we only include the ones that match the given path
@@ -353,7 +353,7 @@ func (gui *Gui) resetState() {
Commits: make([]*models.Commit, 0),
FilteredReflogCommits: make([]*models.Commit, 0),
ReflogCommits: make([]*models.Commit, 0),
- StashEntries: make([]*commands.StashEntry, 0),
+ StashEntries: make([]*models.StashEntry, 0),
Panels: &panelStates{
// TODO: work out why some of these are -1 and some are 0. Last time I checked there was a good reason but I'm less certain now
Files: &filePanelState{listPanelState{SelectedLineIdx: -1}},
diff --git a/pkg/gui/presentation/stash_entries.go b/pkg/gui/presentation/stash_entries.go
index d1f54cc8a..d9985fcba 100644
--- a/pkg/gui/presentation/stash_entries.go
+++ b/pkg/gui/presentation/stash_entries.go
@@ -1,12 +1,12 @@
package presentation
import (
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetStashEntryListDisplayStrings(stashEntries []*commands.StashEntry, diffName string) [][]string {
+func GetStashEntryListDisplayStrings(stashEntries []*models.StashEntry, diffName string) [][]string {
lines := make([][]string, len(stashEntries))
for i := range stashEntries {
@@ -18,7 +18,7 @@ func GetStashEntryListDisplayStrings(stashEntries []*commands.StashEntry, diffNa
}
// getStashEntryDisplayStrings returns the display string of branch
-func getStashEntryDisplayStrings(s *commands.StashEntry, diffed bool) []string {
+func getStashEntryDisplayStrings(s *models.StashEntry, diffed bool) []string {
attr := theme.DefaultTextColor
if diffed {
attr = theme.DiffTerminalColor
diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go
index 71f246417..765163408 100644
--- a/pkg/gui/stash_panel.go
+++ b/pkg/gui/stash_panel.go
@@ -2,12 +2,12 @@ package gui
import (
"github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/models"
)
// list panel functions
-func (gui *Gui) getSelectedStashEntry() *commands.StashEntry {
+func (gui *Gui) getSelectedStashEntry() *models.StashEntry {
selectedLine := gui.State.Panels.Stash.SelectedLineIdx
if selectedLine == -1 {
return nil
diff --git a/pkg/commands/stash_entry.go b/pkg/models/stash_entry.go
index bdb899a75..efda6bc77 100644
--- a/pkg/commands/stash_entry.go
+++ b/pkg/models/stash_entry.go
@@ -1,4 +1,4 @@
-package commands
+package models
import "fmt"