mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
move stash panel
This commit is contained in:
parent
8d2af5cc61
commit
91f0b0e28f
7 changed files with 21 additions and 20 deletions
|
@ -200,10 +200,10 @@ func findDotGitDir(stat func(string) (os.FileInfo, error), readFile func(filenam
|
||||||
return strings.TrimSpace(strings.TrimPrefix(fileContent, "gitdir: ")), nil
|
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'"
|
unescaped := "git stash list --pretty='%gs'"
|
||||||
rawString, _ := c.OSCommand.RunCommandWithOutput(unescaped)
|
rawString, _ := c.OSCommand.RunCommandWithOutput(unescaped)
|
||||||
stashEntries := []*StashEntry{}
|
stashEntries := []*models.StashEntry{}
|
||||||
for i, line := range utils.SplitLines(rawString) {
|
for i, line := range utils.SplitLines(rawString) {
|
||||||
stashEntries = append(stashEntries, stashEntryFromLine(line, i))
|
stashEntries = append(stashEntries, stashEntryFromLine(line, i))
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ func (c *GitCommand) getUnfilteredStashEntries() []*StashEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStashEntries stash entries
|
// GetStashEntries stash entries
|
||||||
func (c *GitCommand) GetStashEntries(filterPath string) []*StashEntry {
|
func (c *GitCommand) GetStashEntries(filterPath string) []*models.StashEntry {
|
||||||
if filterPath == "" {
|
if filterPath == "" {
|
||||||
return c.getUnfilteredStashEntries()
|
return c.getUnfilteredStashEntries()
|
||||||
}
|
}
|
||||||
|
@ -221,8 +221,8 @@ func (c *GitCommand) GetStashEntries(filterPath string) []*StashEntry {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.getUnfilteredStashEntries()
|
return c.getUnfilteredStashEntries()
|
||||||
}
|
}
|
||||||
stashEntries := []*StashEntry{}
|
stashEntries := []*models.StashEntry{}
|
||||||
var currentStashEntry *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+)\}`)
|
||||||
|
@ -249,8 +249,8 @@ outer:
|
||||||
return stashEntries
|
return stashEntries
|
||||||
}
|
}
|
||||||
|
|
||||||
func stashEntryFromLine(line string, index int) *StashEntry {
|
func stashEntryFromLine(line string, index int) *models.StashEntry {
|
||||||
return &StashEntry{
|
return &models.StashEntry{
|
||||||
Name: line,
|
Name: line,
|
||||||
Index: index,
|
Index: index,
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
gogit "github.com/go-git/go-git/v5"
|
gogit "github.com/go-git/go-git/v5"
|
||||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/test"
|
"github.com/jesseduffield/lazygit/pkg/test"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
@ -260,7 +261,7 @@ func TestGitCommandGetStashEntries(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
testName string
|
testName string
|
||||||
command func(string, ...string) *exec.Cmd
|
command func(string, ...string) *exec.Cmd
|
||||||
test func([]*StashEntry)
|
test func([]*models.StashEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
|
@ -269,7 +270,7 @@ func TestGitCommandGetStashEntries(t *testing.T) {
|
||||||
func(string, ...string) *exec.Cmd {
|
func(string, ...string) *exec.Cmd {
|
||||||
return exec.Command("echo")
|
return exec.Command("echo")
|
||||||
},
|
},
|
||||||
func(entries []*StashEntry) {
|
func(entries []*models.StashEntry) {
|
||||||
assert.Len(t, entries, 0)
|
assert.Len(t, entries, 0)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -278,8 +279,8 @@ func TestGitCommandGetStashEntries(t *testing.T) {
|
||||||
func(string, ...string) *exec.Cmd {
|
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")
|
return exec.Command("echo", "WIP on add-pkg-commands-test: 55c6af2 increase parallel build\nWIP on master: bb86a3f update github template")
|
||||||
},
|
},
|
||||||
func(entries []*StashEntry) {
|
func(entries []*models.StashEntry) {
|
||||||
expected := []*StashEntry{
|
expected := []*models.StashEntry{
|
||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
"WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
|
"WIP on add-pkg-commands-test: 55c6af2 increase parallel build",
|
||||||
|
|
|
@ -22,7 +22,7 @@ type CustomCommandObjects struct {
|
||||||
SelectedRemoteBranch *models.RemoteBranch
|
SelectedRemoteBranch *models.RemoteBranch
|
||||||
SelectedRemote *models.Remote
|
SelectedRemote *models.Remote
|
||||||
SelectedTag *models.Tag
|
SelectedTag *models.Tag
|
||||||
SelectedStashEntry *commands.StashEntry
|
SelectedStashEntry *models.StashEntry
|
||||||
SelectedCommitFile *commands.CommitFile
|
SelectedCommitFile *commands.CommitFile
|
||||||
CheckedOutBranch *models.Branch
|
CheckedOutBranch *models.Branch
|
||||||
PromptResponses []string
|
PromptResponses []string
|
||||||
|
|
|
@ -276,7 +276,7 @@ type guiState struct {
|
||||||
SubmoduleConfigs []*models.SubmoduleConfig
|
SubmoduleConfigs []*models.SubmoduleConfig
|
||||||
Branches []*models.Branch
|
Branches []*models.Branch
|
||||||
Commits []*models.Commit
|
Commits []*models.Commit
|
||||||
StashEntries []*commands.StashEntry
|
StashEntries []*models.StashEntry
|
||||||
CommitFiles []*commands.CommitFile
|
CommitFiles []*commands.CommitFile
|
||||||
// FilteredReflogCommits are the ones that appear in the reflog panel.
|
// FilteredReflogCommits are the ones that appear in the reflog panel.
|
||||||
// when in filtering mode we only include the ones that match the given path
|
// 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),
|
Commits: make([]*models.Commit, 0),
|
||||||
FilteredReflogCommits: make([]*models.Commit, 0),
|
FilteredReflogCommits: make([]*models.Commit, 0),
|
||||||
ReflogCommits: make([]*models.Commit, 0),
|
ReflogCommits: make([]*models.Commit, 0),
|
||||||
StashEntries: make([]*commands.StashEntry, 0),
|
StashEntries: make([]*models.StashEntry, 0),
|
||||||
Panels: &panelStates{
|
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
|
// 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}},
|
Files: &filePanelState{listPanelState{SelectedLineIdx: -1}},
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package presentation
|
package presentation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"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))
|
lines := make([][]string, len(stashEntries))
|
||||||
|
|
||||||
for i := range stashEntries {
|
for i := range stashEntries {
|
||||||
|
@ -18,7 +18,7 @@ func GetStashEntryListDisplayStrings(stashEntries []*commands.StashEntry, diffNa
|
||||||
}
|
}
|
||||||
|
|
||||||
// getStashEntryDisplayStrings returns the display string of branch
|
// 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
|
attr := theme.DefaultTextColor
|
||||||
if diffed {
|
if diffed {
|
||||||
attr = theme.DiffTerminalColor
|
attr = theme.DiffTerminalColor
|
||||||
|
|
|
@ -2,12 +2,12 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// list panel functions
|
// list panel functions
|
||||||
|
|
||||||
func (gui *Gui) getSelectedStashEntry() *commands.StashEntry {
|
func (gui *Gui) getSelectedStashEntry() *models.StashEntry {
|
||||||
selectedLine := gui.State.Panels.Stash.SelectedLineIdx
|
selectedLine := gui.State.Panels.Stash.SelectedLineIdx
|
||||||
if selectedLine == -1 {
|
if selectedLine == -1 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package commands
|
package models
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue