diff options
76 files changed, 513 insertions, 369 deletions
@@ -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 ) @@ -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= @@ -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 |