mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-21 22:43:27 +02:00
Use DiffContextSize
in ShowStashEntryCmdStr
This commit is contained in:
parent
ecfafb6fbe
commit
c99d373e13
@ -15,7 +15,7 @@ func (c *GitCommand) StashSave(message string) error {
|
|||||||
|
|
||||||
// GetStashEntryDiff stash diff
|
// GetStashEntryDiff stash diff
|
||||||
func (c *GitCommand) ShowStashEntryCmdStr(index int) string {
|
func (c *GitCommand) ShowStashEntryCmdStr(index int) string {
|
||||||
return fmt.Sprintf("git stash show -p --stat --color=%s stash@{%d}", c.colorArg(), index)
|
return fmt.Sprintf("git stash show -p --stat --color=%s --unified=%d stash@{%d}", c.colorArg(), c.Config.GetUserConfig().Git.DiffContextSize, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StashSaveStagedChanges stashes only the currently staged changes. This takes a few steps
|
// StashSaveStagedChanges stashes only the currently staged changes. This takes a few steps
|
||||||
|
@ -33,3 +33,37 @@ func TestGitCommandStashSave(t *testing.T) {
|
|||||||
|
|
||||||
assert.NoError(t, gitCmd.StashSave("A stash message"))
|
assert.NoError(t, gitCmd.StashSave("A stash message"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestGitCommandShowStashEntryCmdStr is a function.
|
||||||
|
func TestGitCommandShowStashEntryCmdStr(t *testing.T) {
|
||||||
|
type scenario struct {
|
||||||
|
testName string
|
||||||
|
index int
|
||||||
|
contextSize int
|
||||||
|
expected string
|
||||||
|
}
|
||||||
|
|
||||||
|
scenarios := []scenario{
|
||||||
|
{
|
||||||
|
testName: "Default case",
|
||||||
|
index: 5,
|
||||||
|
contextSize: 3,
|
||||||
|
expected: "git stash show -p --stat --color=always --unified=3 stash@{5}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testName: "Show diff with custom context size",
|
||||||
|
index: 5,
|
||||||
|
contextSize: 77,
|
||||||
|
expected: "git stash show -p --stat --color=always --unified=77 stash@{5}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, s := range scenarios {
|
||||||
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
|
gitCmd := NewDummyGitCommand()
|
||||||
|
gitCmd.Config.GetUserConfig().Git.DiffContextSize = s.contextSize
|
||||||
|
cmdStr := gitCmd.ShowStashEntryCmdStr(s.index)
|
||||||
|
assert.Equal(t, s.expected, cmdStr)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user