summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-31 22:11:34 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit2a1e3faa0c61cc8c2418310089485dbab268228f (patch)
tree742988b455946b12a84adccb950b8df5a631417b
parenteb056576cfe7d97503ef1baf3e1730c87d63976f (diff)
resetting controllers on new repo
-rw-r--r--go.mod4
-rw-r--r--go.sum8
-rw-r--r--main.go4
-rw-r--r--pkg/app/app.go8
-rw-r--r--pkg/cheatsheet/generate.go2
-rw-r--r--pkg/gui/branches_panel.go30
-rw-r--r--pkg/gui/commit_files_panel.go10
-rw-r--r--pkg/gui/commits_panel.go6
-rw-r--r--pkg/gui/controllers/files_controller.go4
-rw-r--r--pkg/gui/controllers/files_helper.go (renamed from pkg/gui/file_helper.go)11
-rw-r--r--pkg/gui/controllers/local_commits_controller.go12
-rw-r--r--pkg/gui/controllers/refs_helper.go (renamed from pkg/gui/refs_helper.go)52
-rw-r--r--pkg/gui/controllers/suggestions_helper.go (renamed from pkg/gui/suggestions_helper.go)43
-rw-r--r--pkg/gui/controllers/types.go30
-rw-r--r--pkg/gui/controllers/working_tree_helper.go (renamed from pkg/gui/working_tree_helper.go)24
-rw-r--r--pkg/gui/diffing.go2
-rw-r--r--pkg/gui/dummies.go2
-rw-r--r--pkg/gui/filtering_menu_panel.go2
-rw-r--r--pkg/gui/gui.go226
-rw-r--r--pkg/gui/gui_test.go1
-rw-r--r--pkg/gui/keybindings.go12
-rw-r--r--pkg/gui/layout.go6
-rw-r--r--pkg/gui/line_by_line_panel.go2
-rw-r--r--pkg/gui/list_context_config.go50
-rw-r--r--pkg/gui/misc.go2
-rw-r--r--pkg/gui/modes.go8
-rw-r--r--pkg/gui/patch_options_panel.go20
-rw-r--r--pkg/gui/pull_request_menu_panel.go2
-rw-r--r--pkg/gui/recent_repos_panel.go18
-rw-r--r--pkg/gui/reflog_panel.go10
-rw-r--r--pkg/gui/refresh.go40
-rw-r--r--pkg/gui/remote_branches_panel.go8
-rw-r--r--pkg/gui/remotes_panel.go4
-rw-r--r--pkg/gui/stash_panel.go4
-rw-r--r--pkg/gui/status_panel.go6
-rw-r--r--pkg/gui/sub_commits_panel.go14
-rw-r--r--pkg/gui/submodules_panel.go6
-rw-r--r--pkg/gui/types/common.go29
-rw-r--r--pkg/gui/workspace_reset_options_panel.go2
-rw-r--r--vendor/github.com/go-errors/errors/README.md1
-rw-r--r--vendor/github.com/go-errors/errors/stackframe.go14
-rw-r--r--vendor/github.com/jesseduffield/gocui/gui.go8
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux.go23
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_386.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_arm.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mips.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go3
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_386.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go1
-rw-r--r--vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go1
-rw-r--r--vendor/golang.org/x/sys/unix/ztypes_linux.go32
-rw-r--r--vendor/golang.org/x/sys/windows/syscall_windows.go2
-rw-r--r--vendor/golang.org/x/sys/windows/types_windows.go2
-rw-r--r--vendor/golang.org/x/sys/windows/zsyscall_windows.go14
-rw-r--r--vendor/modules.txt6
76 files changed, 513 insertions, 369 deletions
diff --git a/go.mod b/go.mod
index f4f67183d..0cde50810 100644
--- a/go.mod
+++ b/go.mod
@@ -20,7 +20,7 @@ require (
github.com/imdario/mergo v0.3.11
github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
- github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b
+ github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
github.com/jesseduffield/yaml v2.1.0+incompatible
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
@@ -42,7 +42,7 @@ require (
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect
golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect
- golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
+ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0
)
diff --git a/go.sum b/go.sum
index e0e58cd81..1b3593e93 100644
--- a/go.sum
+++ b/go.sum
@@ -41,8 +41,8 @@ github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447/go.mod h1:I8YJF
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
-github.com/go-errors/errors v1.4.1 h1:IvVlgbzSsaUNudsw5dcXSzF3EWyXTi5XrAdngnuhRyg=
-github.com/go-errors/errors v1.4.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
+github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
+github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
@@ -73,8 +73,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg=
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
-github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b h1:AUK5nDiPiaahBtGIsf8rITgZ9SC+uddvnNKs0/mrYA8=
-github.com/jesseduffield/gocui v0.3.1-0.20220108045521-1945d7b9ed8b/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
+github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba h1:5czcvu7MjSzrS12qPCLhh6yiE2eRz+tZCybH7Q85TpM=
+github.com/jesseduffield/gocui v0.3.1-0.20220131110921-82fe47ec96ba/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e h1:uw/oo+kg7t/oeMs6sqlAwr85ND/9cpO3up3VxphxY0U=
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e/go.mod h1:u60qdFGXRd36jyEXxetz0vQceQIxzI13lIo3EFUDf4I=
github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE=
diff --git a/main.go b/main.go
index c6c097146..7d071cda2 100644
--- a/main.go
+++ b/main.go
@@ -132,10 +132,10 @@ func main() {
log.Fatal(err.Error())
}
- app, err := app.NewApp(appConfig, filterPath)
+ app, err := app.NewApp(appConfig)
if err == nil {
- err = app.Run()
+ err = app.Run(filterPath)
}
if err != nil {
diff --git a/pkg/app/app.go b/pkg/app/app.go
index f38dcb75e..0ee7e4adf 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -94,7 +94,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
}
// NewApp bootstrap a new application
-func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
+func NewApp(config config.AppConfigurer) (*App, error) {
userConfig := config.GetUserConfig()
app := &App{
@@ -140,7 +140,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
gitConfig := git_config.NewStdCachedGitConfig(app.Log)
- app.Gui, err = gui.NewGui(app.Common, config, gitConfig, app.Updater, filterPath, showRecentRepos, dirName)
+ app.Gui, err = gui.NewGui(app.Common, config, gitConfig, app.Updater, showRecentRepos, dirName)
if err != nil {
return app, err
}
@@ -241,7 +241,7 @@ func (app *App) setupRepo() (bool, error) {
return false, nil
}
-func (app *App) Run() error {
+func (app *App) Run(filterPath string) error {
if app.ClientContext == "INTERACTIVE_REBASE" {
return app.Rebase()
}
@@ -250,7 +250,7 @@ func (app *App) Run() error {
os.Exit(0)
}
- err := app.Gui.RunAndHandleError()
+ err := app.Gui.RunAndHandleError(filterPath)
return err
}
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go
index 3d1b5efcf..15e390356 100644
--- a/pkg/cheatsheet/generate.go
+++ b/pkg/cheatsheet/generate.go
@@ -41,7 +41,7 @@ func generateAtDir(cheatsheetDir string) {
for lang := range translationSetsByLang {
mConfig.GetUserConfig().Gui.Language = lang
- mApp, _ := app.NewApp(mConfig, "")
+ mApp, _ := app.NewApp(mConfig)
path := cheatsheetDir + "/Keybindings_" + lang + ".md"
file, err := os.Create(path)
if err != nil {
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 9cf0d740a..f295c9470 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -14,7 +14,7 @@ import (
// list panel functions
func (gui *Gui) getSelectedBranch() *models.Branch {
- if len(gui.State.Branches) == 0 {
+ if len(gui.State.Model.Branches) == 0 {
return nil
}
@@ -23,7 +23,7 @@ func (gui *Gui) getSelectedBranch() *models.Branch {
return nil
}
- return gui.State.Branches[selectedLine]
+ return gui.State.Model.Branches[selectedLine]
}
func (gui *Gui) branchesRenderToMain() error {
@@ -56,7 +56,7 @@ func (gui *Gui) handleBranchPress() error {
}
branch := gui.getSelectedBranch()
gui.c.LogAction(gui.c.Tr.Actions.CheckoutBranch)
- return gui.helpers.refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{})
+ return gui.helpers.Refs.CheckoutRef(branch.Name, types.CheckoutRefOptions{})
}
func (gui *Gui) handleCreatePullRequestPress() error {
@@ -129,10 +129,10 @@ func (gui *Gui) handleForceCheckout() error {
func (gui *Gui) handleCheckoutByName() error {
return gui.c.Prompt(types.PromptOpts{
Title: gui.c.Tr.BranchName + ":",
- FindSuggestionsFunc: gui.helpers.suggestions.GetRefsSuggestionsFunc(),
+ FindSuggestionsFunc: gui.helpers.Suggestions.GetRefsSuggestionsFunc(),
HandleConfirm: func(response string) error {
gui.c.LogAction("Checkout branch")
- return gui.helpers.refs.CheckoutRef(response, types.CheckoutRefOptions{
+ return gui.helpers.Refs.CheckoutRef(response, types.CheckoutRefOptions{
OnRefNotFound: func(ref string) error {
return gui.c.Ask(types.AskOpts{
Title: gui.c.Tr.BranchNotFoundTitle,
@@ -148,11 +148,11 @@ func (gui *Gui) handleCheckoutByName() error {
}
func (gui *Gui) getCheckedOutBranch() *models.Branch {
- if len(gui.State.Branches) == 0 {
+ if len(gui.State.Model.Branches) == 0 {
return nil
}
- return gui.State.Branches[0]
+ return gui.State.Model.Branches[0]
}
func (gui *Gui) createNewBranchWithName(newBranchName string) error {
@@ -239,7 +239,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.Merge)
err := gui.git.Branch.Merge(branchName, git_commands.MergeOpts{})
- return gui.helpers.rebase.CheckMergeOrRebase(err)
+ return gui.helpers.Rebase.CheckMergeOrRebase(err)
},
})
}
@@ -273,7 +273,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
HandleConfirm: func() error {
gui.c.LogAction(gui.c.Tr.Actions.RebaseBranch)
err := gui.git.Rebase.RebaseBranch(selectedBranchName)
- return gui.helpers.rebase.CheckMergeOrRebase(err)
+ return gui.helpers.Rebase.CheckMergeOrRebase(err)
},
})
}
@@ -339,7 +339,7 @@ func (gui *Gui) handleCreateResetToBranchMenu() error {
return nil
}
- return gui.helpers.refs.CreateGitResetMenu(branch.Name)
+ return gui.helpers.Refs.CreateGitResetMenu(branch.Name)
}
func (gui *Gui) handleRenameBranch() error {
@@ -362,7 +362,7 @@ func (gui *Gui) handleRenameBranch() error {
gui.refreshBranches()
// now that we've got our stuff again we need to find that branch and reselect it.
- for i, newBranch := range gui.State.Branches {
+ for i, newBranch := range gui.State.Model.Branches {
if newBranch.Name == newBranchName {
gui.State.Panels.Branches.SetSelectedLineIdx(i)
if err := gui.State.Contexts.Branches.HandleRender(); err != nil {
@@ -390,12 +390,6 @@ func (gui *Gui) handleRenameBranch() error {
})
}
-// sanitizedBranchName will remove all spaces in favor of a dash "-" to meet
-// git's branch naming requirement.
-func sanitizedBranchName(input string) string {
- return strings.Replace(input, " ", "-", -1)
-}
-
func (gui *Gui) handleEnterBranch() error {
branch := gui.getSelectedBranch()
if branch == nil {
@@ -411,5 +405,5 @@ func (gui *Gui) handleNewBranchOffBranch() error {
return nil
}
- return gui.helpers.refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), "")
+ return gui.helpers.Refs.NewBranch(selectedBranch.RefName(), selectedBranch.RefName(), "")
}
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 8e6410b9e..f55b3d6c3 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -82,8 +82,8 @@ func (gui *Gui) handleDiscardOldFileChange() error {
HandleConfirm: func() error {
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
gui.c.LogAction(gui.c.Tr.Actions.DiscardOldFileChange)
- if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
- if err := gui.helpers.rebase.CheckMergeOrRebase(err); err != nil {
+ if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Panels.Commits.SelectedLineIdx, fileName); err != nil {
+ if err := gui.helpers.Rebase.CheckMergeOrRebase(err); err != nil {
return err
}
}
@@ -109,7 +109,7 @@ func (gui *Gui) refreshCommitFilesView() error {
if err != nil {
return gui.c.Error(err)
}
- gui.State.CommitFiles = files
+ gui.State.Model.CommitFiles = files
gui.State.Contexts.CommitFiles.CommitFileTreeViewModel.SetTree()
return gui.c.PostRefreshUpdate(gui.State.Contexts.CommitFiles)
@@ -121,7 +121,7 @@ func (gui *Gui) handleOpenOldCommitFile() error {
return nil
}
- return gui.helpers.files.OpenFile(node.GetPath())
+ return gui.helpers.Files.OpenFile(node.GetPath())
}
func (gui *Gui) handleEditCommitFile() error {
@@ -134,7 +134,7 @@ func (gui *Gui) handleEditCommitFile() error {
return gui.c.ErrorMsg(gui.c.Tr.ErrCannotEditDirectory)
}
- return gui.helpers.files.EditFile(node.GetPath())
+ return gui.helpers.Files.EditFile(node.GetPath())
}
func (gui *Gui) handleToggleFileForPatch() error {
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index b2233f377..4175918ea 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -12,11 +12,11 @@ const COMMIT_THRESHOLD = 200
func (gui *Gui) getSelectedLocalCommit() *models.Commit {
selectedLine := gui.State.Panels.Commits.SelectedLineIdx
- if selectedLine == -1 || selectedLine > len(gui.State.Commits)-1 {
+ if selectedLine == -1 || selectedLine > len(gui.State.Model.Commits)-1 {
return nil
}
- return gui.State.Commits[selectedLine]
+ return gui.State.Model.Commits[selectedLine]
}
func (gui *Gui) onCommitFocus() error {
@@ -56,7 +56,7 @@ func (gui *Gui) branchCommitsRenderToMain() error {
func (gui *Gui) refForLog() string {
bisectInfo := gui.git.Bisect.GetInfo()
- gui.State.BisectInfo = bisectInfo
+ gui.State.Model.BisectInfo = bisectInfo
if !bisectInfo.Started() {
return "HEAD"
diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go
index 9209a96b3..57df2e84e 100644
--- a/pkg/gui/controllers/files_controller.go
+++ b/pkg/gui/controllers/files_controller.go
@@ -40,7 +40,7 @@ type FilesController struct {
switchToMergeFn func(path string) error
suggestionsHelper ISuggestionsHelper
refsHelper IRefsHelper
- filesHelper IFileHelper
+ filesHelper IFilesHelper
workingTreeHelper IWorkingTreeHelper
}
@@ -64,7 +64,7 @@ func NewFilesController(
switchToMergeFn func(path string) error,
suggestionsHelper ISuggestionsHelper,
refsHelper IRefsHelper,
- filesHelper IFileHelper,
+ filesHelper IFilesHelper,
workingTreeHelper IWorkingTreeHelper,
) *FilesController {
return &FilesController{
diff --git a/pkg/gui/file_helper.go b/pkg/gui/controllers/files_helper.go
index 2e32e168f..c3706cc72 100644
--- a/pkg/gui/file_helper.go
+++ b/pkg/gui/controllers/files_helper.go
@@ -1,12 +1,17 @@
-package gui
+package controllers
import (
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
- "github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)