mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-15 22:26:40 +02:00
Fix crash when viewing the divergence of a branch which is up to date with its upstream
This was introduced by #3838, specifically by commit e675025411. Add a regression test that would have crashed without the fix.
This commit is contained in:
parent
4dadcd2ace
commit
f8073c7188
@ -121,7 +121,10 @@ func (self *ListRenderer) insertNonModelItems(
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if item.Index+offset >= startIdx {
|
if item.Index+offset >= startIdx {
|
||||||
padding := strings.Repeat(" ", columnPositions[item.Column])
|
padding := ""
|
||||||
|
if columnPositions != nil {
|
||||||
|
padding = strings.Repeat(" ", columnPositions[item.Column])
|
||||||
|
}
|
||||||
lines = slices.Insert(lines, item.Index+offset-startIdx, padding+item.Content)
|
lines = slices.Insert(lines, item.Index+offset-startIdx, padding+item.Content)
|
||||||
}
|
}
|
||||||
offset++
|
offset++
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package branch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ShowDivergenceFromUpstreamNoDivergence = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Show divergence from upstream when the divergence view is empty",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.EmptyCommit("commit1")
|
||||||
|
shell.CloneIntoRemote("origin")
|
||||||
|
shell.SetBranchUpstream("master", "origin/master")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Branches().
|
||||||
|
Focus().
|
||||||
|
Lines(Contains("master")).
|
||||||
|
Press(keys.Branches.SetUpstream)
|
||||||
|
|
||||||
|
t.ExpectPopup().Menu().Title(Contains("Upstream")).Select(Contains("View divergence from upstream")).Confirm()
|
||||||
|
|
||||||
|
t.Views().SubCommits().
|
||||||
|
IsFocused().
|
||||||
|
Title(Contains("Commits (master <-> origin/master)")).
|
||||||
|
Lines(
|
||||||
|
Contains("--- Remote ---"),
|
||||||
|
Contains("--- Local ---"),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
@ -65,6 +65,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
branch.SetUpstream,
|
branch.SetUpstream,
|
||||||
branch.ShowDivergenceFromBaseBranch,
|
branch.ShowDivergenceFromBaseBranch,
|
||||||
branch.ShowDivergenceFromUpstream,
|
branch.ShowDivergenceFromUpstream,
|
||||||
|
branch.ShowDivergenceFromUpstreamNoDivergence,
|
||||||
branch.SortLocalBranches,
|
branch.SortLocalBranches,
|
||||||
branch.SortRemoteBranches,
|
branch.SortRemoteBranches,
|
||||||
branch.SquashMerge,
|
branch.SquashMerge,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user