Skip to content
Open
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
4 changes: 4 additions & 0 deletions docs-master/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ gui:
# is true.
expandedSidePanelWeight: 2

# If true, the expanded side panel will only expand as much as its content
# requires. Only relevant if `expandFocusedSidePanel` is true.
expandedFocusedSidePanelFitsContent: false

# Sometimes the main window is split in two (e.g. when the selected file has
# both staged and unstaged changes). This setting controls how the two sections
# are split.
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/entry_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ func parseGitArg(gitArg string) appTypes.GitArg {
string(appTypes.GitArgStash),
}

log.Fatalf("Invalid git arg value: '%s'. Must be one of the following values: %s. e.g. 'lazygit status'. See 'lazygit --help'.",
log.Fatalf(
"Invalid git arg value: '%s'. Must be one of the following values: %s. e.g. 'lazygit status'. See 'lazygit --help'.",
gitArg,
strings.Join(permittedValues, ", "),
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/git_commands/branch_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ func TestGetBehindBaseBranchValuesForAllBranches_FastPath_ClearsStaleValueWhenBr
}

err := loader.GetBehindBaseBranchValuesForAllBranches(
[]*models.Branch{feat, ghost}, mainBranches, func() {})
[]*models.Branch{feat, ghost}, mainBranches, func() {},
)
assert.NoError(t, err)

assert.Equal(t, int32(5), feat.BehindBaseBranch.Load(), "feat-x should be updated to fresh value")
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/git_commands/branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ func TestBranchCurrentBranchInfo(t *testing.T) {
[]string{"branch", "--points-at=HEAD", "--format=%(HEAD)%00%(objectname)%00%(refname)"},
"*\x00679b0456f3db7c505b398def84e7d023e5b55a8d\x00(头指针在 679b0456 分离)\n"+
" \x00679b0456f3db7c505b398def84e7d023e5b55a8d\x00refs/heads/master\n",
nil),
nil,
),
func(info BranchInfo, err error) {
assert.NoError(t, err)
assert.EqualValues(t, "679b0456f3db7c505b398def84e7d023e5b55a8d", info.RefName)
Expand Down
15 changes: 10 additions & 5 deletions pkg/commands/git_commands/file_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ func TestFileGetStatusFiles(t *testing.T) {
testName: "Several files found",
similarityThreshold: 50,
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
ExpectGitArgs(
[]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
"MM file1.txt\x00A file3.txt\x00AM file2.txt\x00?? file4.txt\x00UU file5.txt",
nil,
).
ExpectGitArgs([]string{"diff", "--numstat", "-z", "HEAD"},
ExpectGitArgs(
[]string{"diff", "--numstat", "-z", "HEAD"},
"4\t1\tfile1.txt\x001\t0\tfile2.txt\x002\t2\tfile3.txt\x000\t2\tfile4.txt\x002\t2\tfile5.txt",
nil,
),
Expand Down Expand Up @@ -136,7 +138,8 @@ func TestFileGetStatusFiles(t *testing.T) {
testName: "Renamed files",
similarityThreshold: 50,
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
ExpectGitArgs(
[]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
"R after1.txt\x00before1.txt\x00RM after2.txt\x00before2.txt",
nil,
),
Expand Down Expand Up @@ -173,7 +176,8 @@ func TestFileGetStatusFiles(t *testing.T) {
testName: "File with arrow in name",
similarityThreshold: 50,
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
ExpectGitArgs(
[]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
`?? a -> b.txt`,
nil,
),
Expand All @@ -196,7 +200,8 @@ func TestFileGetStatusFiles(t *testing.T) {
testName: "Copied files",
similarityThreshold: 50,
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
ExpectGitArgs(
[]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"},
"C copy1.txt\x00original.txt\x00CM copy2.txt\x00original.txt",
nil,
),
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/git_commands/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func TestStartCmdObj(t *testing.T) {
t.Run(s.testName, func(t *testing.T) {
instance := buildFlowCommands(commonDeps{})

assert.Equal(t,
assert.Equal(
t,
instance.StartCmdObj(s.branchType, s.branchName).Args(),
s.expected,
)
Expand Down
12 changes: 8 additions & 4 deletions pkg/commands/git_commands/repo_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func TestGetRepoPaths(t *testing.T) {
runner.ExpectGitArgs(
append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"),
strings.Join(mockOutput, "\n"),
nil)
nil,
)
},
Path: "/path/to/repo",
Expected: lo.Ternary(runtime.GOOS == "windows", &RepoPaths{
Expand Down Expand Up @@ -103,7 +104,8 @@ func TestGetRepoPaths(t *testing.T) {
runner.ExpectGitArgs(
append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"),
strings.Join(mockOutput, "\n"),
nil)
nil,
)
},
Path: "/path/to/repo",
Expected: lo.Ternary(runtime.GOOS == "windows", &RepoPaths{
Expand Down Expand Up @@ -152,7 +154,8 @@ func TestGetRepoPaths(t *testing.T) {
runner.ExpectGitArgs(
append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"),
strings.Join(mockOutput, "\n"),
nil)
nil,
)
},
Path: "/path/to/repo/submodule1",
Expected: lo.Ternary(runtime.GOOS == "windows", &RepoPaths{
Expand All @@ -178,7 +181,8 @@ func TestGetRepoPaths(t *testing.T) {
runner.ExpectGitArgs(
append(getRevParseArgs(), "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree"),
"",
errors.New("fatal: invalid gitfile format: /path/to/repo/worktree2/.git"))
errors.New("fatal: invalid gitfile format: /path/to/repo/worktree2/.git"),
)
},
Path: "/path/to/repo/worktree2",
Expected: nil,
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/git_commands/stash_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func TestGetStashEntries(t *testing.T) {
"",
oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"stash", "list", "-z", "--pretty=%H|%ct|%gs"},
fmt.Sprintf("fa1afe1|%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00deadbeef|%d|WIP on master: bb86a3f update github template\x00",
fmt.Sprintf(
"fa1afe1|%d|WIP on add-pkg-commands-test: 55c6af2 increase parallel build\x00deadbeef|%d|WIP on master: bb86a3f update github template\x00",
hoursAgo,
daysAgo,
), nil),
Expand Down
3 changes: 2 additions & 1 deletion pkg/commands/git_commands/working_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ func (self *WorkingTreeCommands) removeEmptyDirs(removedFilePaths []string, sele
lo.FilterMap(removedFilePaths, func(filePath string, _ int) (string, bool) {
dir := path.Dir(filePath)
return dir, dir != "." && isUnderSelectedDir(dir, selectedDirs)
}))
}),
)

for {
var removed []string
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ func migrateAllBranchesLogCmd(rootNode *yaml.Node, changes *ChangesSet) error {
// We will later populate it with the individual allBranchesLogCmd record
cmdsKeyNode = &yaml.Node{Kind: yaml.ScalarNode, Value: "allBranchesLogCmds"}
cmdsValueNode = &yaml.Node{Kind: yaml.SequenceNode, Content: []*yaml.Node{}}
gitNode.Content = append(gitNode.Content,
gitNode.Content = append(
gitNode.Content,
cmdsKeyNode,
cmdsValueNode,
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/editor_presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ type editPreset struct {
suspend func() bool
}

func returnBool(a bool) func() bool { return (func() bool { return a }) }
func returnBool(a bool) func() bool { return func() bool { return a } }

// IF YOU ADD A PRESET TO THIS FUNCTION YOU MUST UPDATE THE `Supported presets` SECTION OF docs/Config.md
func getPreset(shell string, osConfig *OSConfig, guessDefaultEditor func() string) *editPreset {
var nvimRemoteEditTemplate, nvimRemoteEditAtLineTemplate, nvimRemoteOpenDirInEditorTemplate string
// By default fish doesn't have SHELL variable set, but it does have FISH_VERSION since Nov 2012.
if (strings.HasSuffix(shell, "fish")) || (os.Getenv("FISH_VERSION") != "") {
if strings.HasSuffix(shell, "fish") || (os.Getenv("FISH_VERSION") != "") {
nvimRemoteEditTemplate = `begin; if test -z "$NVIM"; nvim -- {{filename}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{filename}}; end; end`
nvimRemoteEditAtLineTemplate = `begin; if test -z "$NVIM"; nvim +{{line}} -- {{filename}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{filename}}; nvim --server "$NVIM" --remote-send ":{{line}}<CR>"; end; end`
nvimRemoteOpenDirInEditorTemplate = `begin; if test -z "$NVIM"; nvim -- {{dir}}; else; nvim --server "$NVIM" --remote-send "q"; nvim --server "$NVIM" --remote-tab {{dir}}; end; end`
Expand Down
41 changes: 22 additions & 19 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ type GuiConfig struct {
ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"`
// The weight of the expanded side panel, relative to the other panels. 2 means twice as tall as the other panels. Only relevant if `expandFocusedSidePanel` is true.
ExpandedSidePanelWeight int `yaml:"expandedSidePanelWeight"`
// If true, the expanded side panel will only expand as much as its content requires. Only relevant if `expandFocusedSidePanel` is true.
ExpandedFocusedSidePanelFitsContent bool `yaml:"expandedFocusedSidePanelFitsContent"`
// Sometimes the main window is split in two (e.g. when the selected file has both staged and unstaged changes). This setting controls how the two sections are split.
// Options are:
// - 'horizontal': split the window horizontally
Expand Down Expand Up @@ -827,25 +829,26 @@ func GetDefaultConfig() *UserConfig {
func GetDefaultConfigForPlatform(platform string) *UserConfig {
return &UserConfig{
Gui: GuiConfig{
ScrollHeight: 2,
ScrollPastBottom: true,
ScrollOffMargin: 2,
ScrollOffBehavior: "margin",
TabWidth: 4,
MouseEvents: true,
SkipAmendWarning: false,
SkipDiscardChangeWarning: false,
SkipStashWarning: false,
SidePanelWidth: 0.3333,
ExpandFocusedSidePanel: false,
ExpandedSidePanelWeight: 2,
MainPanelSplitMode: "flexible",
EnlargedSideViewLocation: "left",
WrapLinesInStagingView: true,
UseHunkModeInStagingView: true,
Language: "auto",
TimeFormat: "02 Jan 06",
ShortTimeFormat: time.Kitchen,
ScrollHeight: 2,
ScrollPastBottom: true,
ScrollOffMargin: 2,
ScrollOffBehavior: "margin",
TabWidth: 4,
MouseEvents: true,
SkipAmendWarning: false,
SkipDiscardChangeWarning: false,
SkipStashWarning: false,
SidePanelWidth: 0.3333,
ExpandFocusedSidePanel: false,
ExpandedSidePanelWeight: 2,
ExpandedFocusedSidePanelFitsContent: false,
MainPanelSplitMode: "flexible",
EnlargedSideViewLocation: "left",
WrapLinesInStagingView: true,
UseHunkModeInStagingView: true,
Language: "auto",
TimeFormat: "02 Jan 06",
ShortTimeFormat: time.Kitchen,
Theme: ThemeConfig{
ActiveBorderColor: []string{"green", "bold"},
SearchingActiveBorderColor: []string{"cyan", "bold"},
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/user_config_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func validateKeybindingsRecurse(path string, node any) error {
} else if value.Kind() == reflect.Slice {
for i := range value.Len() {
if err := validateKeybindingsRecurse(
fmt.Sprintf("%s[%d]", path, i), value.Index(i).Interface()); err != nil {
fmt.Sprintf("%s[%d]", path, i), value.Index(i).Interface(),
); err != nil {
return err
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/gocui/tcell_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ func (g *Gui) pollEvent() GocuiEvent {
if g.playRecording {
select {
case ev := <-g.ReplayedEvents.Keys:
tev = (ev).toTcellEvent()
tev = ev.toTcellEvent()
case ev := <-g.ReplayedEvents.Resizes:
tev = (ev).toTcellEvent()
tev = ev.toTcellEvent()
case ev := <-g.ReplayedEvents.MouseEvents:
tev = (ev).toTcellEvent()
tev = ev.toTcellEvent()
}
} else {
tev = <-Screen.EventQ()
Expand Down
6 changes: 4 additions & 2 deletions pkg/gui/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func (self *BackgroundRoutineMgr) startBackgroundRoutines() {
} else {
self.gui.c.Log.Errorf(
"Value of config option 'refresher.fetchInterval' (%d) is invalid, disabling auto-fetch",
fetchInterval)
fetchInterval,
)
}
}

Expand All @@ -47,7 +48,8 @@ func (self *BackgroundRoutineMgr) startBackgroundRoutines() {
} else {
self.gui.c.Log.Errorf(
"Value of config option 'refresher.refreshInterval' (%d) is invalid, disabling auto-refresh",
refreshInterval)
refreshInterval,
)
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/context/list_context_trait.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func (self *ListContextTrait) FocusLine(scrollIntoView bool) {
oldOrigin, _ := self.GetViewTrait().ViewPortYBounds()

self.GetViewTrait().FocusPoint(
self.ModelIndexToViewIndex(self.list.GetSelectedLineIdx()), scrollIntoView)
self.ModelIndexToViewIndex(self.list.GetSelectedLineIdx()), scrollIntoView,
)
if !inOnSearchSelect {
self.GetView().SetNearestSearchPosition()
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/gui/context/list_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ func (self *ListRenderer) renderLines(startIdx int, endIdx int) string {
}
lines, columnPositions := utils.RenderDisplayStrings(
self.getDisplayStrings(startModelIdx, endModelIdx),
columnAlignments)
columnAlignments,
)
self.columnPositions = columnPositions
lines = self.insertNonModelItems(nonModelItems, endIdx, startIdx, lines, columnPositions)
return strings.Join(lines, "\n")
Expand All @@ -107,7 +108,8 @@ func (self *ListRenderer) prepareConversionArrays(nonModelItems []*NonModelItem)
viewIndicesByModelIndex[i]++
}
modelIndicesByViewIndex = slices.Insert(
modelIndicesByViewIndex, item.Index+offset, modelIndicesByViewIndex[item.Index+offset])
modelIndicesByViewIndex, item.Index+offset, modelIndicesByViewIndex[item.Index+offset],
)
offset++
}
self.viewIndicesByModelIndex = viewIndicesByModelIndex
Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/context/list_renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ func TestListRenderer_renderLines(t *testing.T) {

expectedOutput := strings.Join(lo.Map(
strings.Split(strings.TrimPrefix(s.expectedOutput, "\n"), "\n"),
func(line string, _ int) string { return strings.TrimSpace(line) }), "\n")
func(line string, _ int) string { return strings.TrimSpace(line) },
), "\n")

assert.Equal(t, expectedOutput, self.renderLines(s.startIdx, s.endIdx))
})
Expand Down
6 changes: 4 additions & 2 deletions pkg/gui/context/local_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
c.Model().Commits, func(c *models.Commit) bool {
return c.Status == models.StatusCherryPickingOrReverting ||
c.Status == models.StatusConflicted
})
},
)
if !found {
firstCherryPickOrRevertTodo = 0
}
Expand All @@ -97,7 +98,8 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
_, firstRealCommit, found := lo.FindIndexOf(
c.Model().Commits, func(c *models.Commit) bool {
return !c.IsTODO()
})
},
)
if !found {
firstRealCommit = 0
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/context/main_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func NewMainContext(
Key: key,
Focusable: true,
HighlightOnFocus: false,
})),
}),
),
SearchTrait: NewSearchTrait(c),
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/context/remotes_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func NewRemotesContext(c *ContextCommon) *RemotesContext {

getDisplayStrings := func(_ int, _ int) [][]string {
return presentation.GetRemoteListDisplayStrings(
viewModel.GetItems(), c.Modes().Diffing.Ref, c.State().GetItemOperation, c.Tr, c.UserConfig())
viewModel.GetItems(), c.Modes().Diffing.Ref, c.State().GetItemOperation, c.Tr, c.UserConfig(),
)
}

return &RemotesContext{
Expand Down
6 changes: 4 additions & 2 deletions pkg/gui/context/sub_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func NewSubCommitsContext(
result := []*NonModelItem{}
if viewModel.GetRefToShowDivergenceFrom() != "" {
_, upstreamIdx, found := lo.FindIndexOf(
c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceRight })
c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceRight },
)
if !found {
upstreamIdx = 0
}
Expand All @@ -94,7 +95,8 @@ func NewSubCommitsContext(
})

_, localIdx, found := lo.FindIndexOf(
c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceLeft })
c.Model().SubCommits, func(c *models.Commit) bool { return c.Divergence == models.DivergenceLeft },
)
if !found {
localIdx = len(c.Model().SubCommits)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/context/tags_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func NewTagsContext(
return presentation.GetTagListDisplayStrings(
viewModel.GetItems(),
c.State().GetItemOperation,
c.Modes().Diffing.Ref, c.Tr, c.UserConfig())
c.Modes().Diffing.Ref, c.Tr, c.UserConfig(),
)
}

return &TagsContext{
Expand Down
Loading