mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
fix panic on rebase
This commit is contained in:
parent
5e6e1617aa
commit
ebbdf829e7
@ -50,10 +50,9 @@ func GetCommitListDisplayStrings(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is where my non-TODO commits begin
|
|
||||||
rebaseOffset := indexOfFirstNonTODOCommit(commits)
|
|
||||||
|
|
||||||
end := utils.Min(startIdx+length, len(commits))
|
end := utils.Min(startIdx+length, len(commits))
|
||||||
|
// this is where my non-TODO commits begin
|
||||||
|
rebaseOffset := utils.Min(indexOfFirstNonTODOCommit(commits), end)
|
||||||
|
|
||||||
filteredCommits := commits[startIdx:end]
|
filteredCommits := commits[startIdx:end]
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
|||||||
showGraph bool
|
showGraph bool
|
||||||
bisectInfo *git_commands.BisectInfo
|
bisectInfo *git_commands.BisectInfo
|
||||||
expected string
|
expected string
|
||||||
|
focus bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
testName: "no commits",
|
testName: "no commits",
|
||||||
@ -174,10 +175,36 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
|||||||
sha5 ◯ commit5
|
sha5 ◯ commit5
|
||||||
`),
|
`),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testName: "only TODO commits except last",
|
||||||
|
commits: []*models.Commit{
|
||||||
|
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}, Action: "pick"},
|
||||||
|
{Name: "commit2", Sha: "sha2", Parents: []string{"sha3"}, Action: "pick"},
|
||||||
|
{Name: "commit3", Sha: "sha3", Parents: []string{"sha4"}, Action: "pick"},
|
||||||
|
{Name: "commit4", Sha: "sha4", Parents: []string{"sha5"}, Action: "pick"},
|
||||||
|
{Name: "commit5", Sha: "sha5", Parents: []string{"sha7"}},
|
||||||
|
},
|
||||||
|
startIdx: 0,
|
||||||
|
length: 2,
|
||||||
|
showGraph: true,
|
||||||
|
bisectInfo: git_commands.NewNullBisectInfo(),
|
||||||
|
expected: formatExpected(`
|
||||||
|
sha1 pick commit1
|
||||||
|
sha2 pick commit2
|
||||||
|
`),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
focusing := false
|
||||||
|
for _, scenario := range scenarios {
|
||||||
|
if scenario.focus {
|
||||||
|
focusing = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
s := s
|
s := s
|
||||||
|
if !focusing || s.focus {
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
result := GetCommitListDisplayStrings(
|
result := GetCommitListDisplayStrings(
|
||||||
s.commits,
|
s.commits,
|
||||||
@ -198,4 +225,5 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
|||||||
assert.EqualValues(t, s.expected, renderedResult)
|
assert.EqualValues(t, s.expected, renderedResult)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user