Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when viewing the divergence of a branch which is up to date with its upstream #3918

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/gui/context/list_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ func (self *ListRenderer) insertNonModelItems(
break
}
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)
}
offset++
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ---"),
)
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var tests = []*components.IntegrationTest{
branch.SetUpstream,
branch.ShowDivergenceFromBaseBranch,
branch.ShowDivergenceFromUpstream,
branch.ShowDivergenceFromUpstreamNoDivergence,
branch.SortLocalBranches,
branch.SortRemoteBranches,
branch.SquashMerge,
Expand Down
Loading