summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-16 14:46:53 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit1dd7307fde033dae5fececac15810a99e26c3d91 (patch)
tree4e851c9e3229a6fe3b4191f6311d05d7a9142960 /pkg
parenta90b6efded49abcfa2516db794d7875b0396f558 (diff)
start moving commit panel handlers into controller
more and more move rebase commit refreshing into existing abstraction and more and more WIP and more handling clicks properly fix merge conflicts update cheatsheet lots more preparation to start moving things into controllers WIP better typing expand on remotes controller moving more code into controllers
Diffstat (limited to 'pkg')
-rw-r--r--pkg/cheatsheet/generate.go17
-rw-r--r--pkg/commands/git.go6
-rw-r--r--pkg/commands/git_commands/common.go6
-rw-r--r--pkg/commands/git_commands/remote.go2
-rw-r--r--pkg/commands/git_commands/sync.go10
-rw-r--r--pkg/commands/git_commands/tag.go2
-rw-r--r--pkg/commands/git_test.go8
-rw-r--r--pkg/commands/oscommands/cmd_obj.go17
-rw-r--r--pkg/commands/oscommands/cmd_obj_runner.go29
-rw-r--r--pkg/gui/app_status_manager.go4
-rw-r--r--pkg/gui/arrangement.go11
-rw-r--r--pkg/gui/basic_context.go26
-rw-r--r--pkg/gui/bisect.go219
-rw-r--r--pkg/gui/branches_panel.go265
-rw-r--r--pkg/gui/cherry_picking.go43
-rw-r--r--pkg/gui/command_log_panel.go14
-rw-r--r--pkg/gui/commit_files_panel.go110
-rw-r--r--pkg/gui/commit_message_panel.go20
-rw-r--r--pkg/gui/commits_panel.go701
-rw-r--r--pkg/gui/confirmation_panel.go21
-rw-r--r--pkg/gui/context.go104
-rw-r--r--pkg/gui/context/context.go98
-rw-r--r--pkg/gui/context_config.go179
-rw-r--r--pkg/gui/controllers/bisect_controller.go273
-rw-r--r--pkg/gui/controllers/controller_common.go10
-rw-r--r--pkg/gui/controllers/files_controller.go737
-rw-r--r--pkg/gui/controllers/local_commits_controller.go783
-rw-r--r--pkg/gui/controllers/menu_controller.go70
-rw-r--r--pkg/gui/controllers/remotes_controller.go204
-rw-r--r--pkg/gui/controllers/submodules_controller.go60
-rw-r--r--pkg/gui/controllers/sync_controller.go253
-rw-r--r--pkg/gui/controllers/tags_controller.go229
-rw-r--r--pkg/gui/controllers/types.go53
-rw-r--r--pkg/gui/controllers/undo_controller.go (renamed from pkg/gui/undoing.go)230
-rw-r--r--pkg/gui/credentials_panel.go15
-rw-r--r--pkg/gui/custom_commands.go66
-rw-r--r--pkg/gui/diff_context_size.go18
-rw-r--r--pkg/gui/diff_context_size_test.go50
-rw-r--r--pkg/gui/diffing.go26
-rw-r--r--pkg/gui/discard_changes_menu_panel.go46
-rw-r--r--pkg/gui/editors.go4
-rw-r--r--pkg/gui/extras_panel.go17
-rw-r--r--pkg/gui/file_helper.go51
-rw-r--r--pkg/gui/file_watching.go4
-rw-r--r--pkg/gui/files_panel.go815
-rw-r--r--pkg/gui/filetree/commit_file_node.go4
-rw-r--r--pkg/gui/filetree/file_node.go4
-rw-r--r--pkg/gui/filtering.go28
-rw-r--r--pkg/gui/filtering_menu_panel.go14
-rw-r--r--pkg/gui/git_flow.go20
-rw-r--r--pkg/gui/global_handlers.go38
-rw-r--r--pkg/gui/gpg.go18
-rw-r--r--pkg/gui/gui.go241
-rw-r--r--pkg/gui/gui_common.go53
-rw-r--r--pkg/gui/information_panel.go10
-rw-r--r--pkg/gui/keybindings.go751
-rw-r--r--pkg/gui/layout.go37
-rw-r--r--pkg/gui/line_by_line_panel.go8
-rw-r--r--pkg/gui/list_context.go116
-rw-r--r--pkg/gui/list_context_config.go204
-rw-r--r--pkg/gui/main_panels.go2
-rw-r--r--pkg/gui/menu_panel.go25
-rw-r--r--pkg/gui/merge_panel.go47
-rw-r--r--pkg/gui/misc.go19
-rw-r--r--pkg/gui/modes.go16
-rw-r--r--pkg/gui/options_menu_panel.go4
-rw-r--r--pkg/gui/patch_building_panel.go24
-rw-r--r--pkg/gui/patch_options_panel.go72
-rw-r--r--pkg/gui/popup/popup_handler.go26
-rw-r--r--pkg/gui/pty.go4
-rw-r--r--pkg/gui/pull_request_menu_panel.go20
-rw-r--r--pkg/gui/quitting.go10
-rw-r--r--pkg/gui/rebase_options_panel.go46
-rw-r--r--pkg/gui/recent_repos_panel.go27
-rw-r--r--pkg/gui/ref_helper.go137
-rw-r--r--pkg/gui/reflog_panel.go31
-rw-r--r--pkg/gui/remote_branches_panel.go36
-rw-r--r--pkg/gui/remotes_panel.go136
-rw-r--r--pkg/gui/reset_menu_panel.go53
-rw-r--r--pkg/gui/searching.go4
-rw-r--r--pkg/gui/staging_panel.go30
-rw-r--r--pkg/gui/stash_panel.go76
-rw-r--r--pkg/gui/status_panel.go22
-rw-r--r--pkg/gui/style/style_test.go15
-rw-r--r--pkg/gui/sub_commits_panel.go31
-rw-r--r--pkg/gui/submodules_panel.go6
-rw-r--r--pkg/gui/suggestions_helper.go (renamed from pkg/gui/find_suggestions.go)90
-rw-r--r--pkg/gui/tags_panel.go106
-rw-r--r--pkg/gui/tasks_adapter.go8
-rw-r--r--pkg/gui/types/common_commands.go7
-rw-r--r--pkg/gui/types/context.go87
-rw-r--r--pkg/gui/types/keybindings.go9
-rw-r--r--pkg/gui/types/refresh.go1
-rw-r--r--pkg/gui/updates.go14
-rw-r--r--pkg/gui/view_helpers.go96
-rw-r--r--pkg/gui/whitespace-toggle.go6
-rw-r--r--pkg/gui/working_tree_helper.go50
-rw-r--r--pkg/gui/workspace_reset_options_panel.go62
-rw-r--r--pkg/i18n/english.go2
99 files changed, 4899 insertions, 4030 deletions
diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go
index 546239df5..3d1b5efcf 100644
--- a/pkg/cheatsheet/generate.go
+++ b/pkg/cheatsheet/generate.go
@@ -17,13 +17,14 @@ import (
"github.com/jesseduffield/lazygit/pkg/app"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/integration"
)
type bindingSection struct {
title string
- bindings []*gui.Binding
+ bindings []*types.Binding
}
func CommandToRun() string {
@@ -113,7 +114,7 @@ func formatTitle(title string) string {
return fmt.Sprintf("\n## %s\n\n", title)
}
-func formatBinding(binding *gui.Binding) string {
+func formatBinding(binding *types.Binding) string {
if binding.Alternative != "" {
return fmt.Sprintf(" <kbd>%s</kbd>: %s (%s)\n", gui.GetKeyDisplay(binding.Key), binding.Description, binding.Alternative)
}
@@ -130,7 +131,7 @@ func getBindingSections(mApp *app.App) []*bindingSection {
title string
}
- contextAndViewBindingMap := map[contextAndViewType][]*gui.Binding{}
+ contextAndViewBindingMap := map[contextAndViewType][]*types.Binding{}
outer:
for _, binding := range bindings {
@@ -138,7 +139,7 @@ outer:
key := contextAndViewType{subtitle: "", title: "navigation"}
existing := contextAndViewBindingMap[key]
if existing == nil {
- contextAndViewBindingMap[key] = []*gui.Binding{binding}
+ contextAndViewBindingMap[key] = []*types.Binding{binding}
} else {
for _, navBinding := range contextAndViewBindingMap[key] {
if navBinding.Description == binding.Description {
@@ -162,7 +163,7 @@ outer:
key := contextAndViewType{subtitle: context, title: binding.ViewName}
existing := contextAndViewBindingMap[key]
if existing == nil {
- contextAndViewBindingMap[key] = []*gui.Binding{binding}
+ contextAndViewBindingMap[key] = []*types.Binding{binding}
} else {
contextAndViewBindingMap[key] = append(contextAndViewBindingMap[key], binding)
}
@@ -171,7 +172,7 @@ outer:
type groupedBindingsType struct {
contextAndView contextAndViewType
- bindings []*gui.Binding
+ bindings []*types.Binding
}
groupedBindings := make([]groupedBindingsType, len(contextAndViewBindingMap))
@@ -227,7 +228,7 @@ outer:
return bindingSections
}
-func addBinding(title string, bindingSections []*bindingSection, binding *gui.Binding) []*bindingSection {
+func addBinding(title string, bindingSections []*bindingSection, binding *types.Binding) []*bindingSection {
if binding.Description == "" && binding.Alternative == "" {
return bindingSections
}
@@ -241,7 +242,7 @@ func addBinding(title string, bindingSections []*bindingSection, binding *gui.Bi
section := &bindingSection{
title: title,
- bindings: []*gui.Binding{binding},
+ bindings: []*types.Binding{binding},
}
return append(bindingSections, section)
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index f6812e254..3880e0dfc 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"strings"
+ "sync"
"github.com/go-errors/errors"
@@ -56,6 +57,7 @@ func NewGitCommand(
cmn *common.Common,
osCommand *oscommands.OSCommand,
gitConfig git_config.IGitConfig,
+ syncMutex *sync.Mutex,
) (*GitCommand, error) {
if err := navigateToRepoRootDirectory(os.Stat, os.Chdir); err != nil {
return nil, err
@@ -77,6 +79,7 @@ func NewGitCommand(
gitConfig,
dotGitDir,
repo,
+ syncMutex,
), nil
}
@@ -86,6 +89,7 @@ func NewGitCommandAux(
gitConfig git_config.IGitConfig,
dotGitDir string,
repo *gogit.Repository,
+ syncMutex *sync.Mutex,
) *GitCommand {
cmd := NewGitCmdObjBuilder(cmn.Log, osCommand.Cmd)
@@ -95,7 +99,7 @@ func NewGitCommandAux(
// on the one struct.
// common ones are: cmn, osCommand, dotGitDir, configCommands
configCommands := git_commands.NewConfigCommands(cmn, gitConfig, repo)
- gitCommon := git_commands.NewGitCommon(cmn, cmd, osCommand, dotGitDir, repo, configCommands)
+ gitCommon := git_commands.NewGitCommon(cmn, cmd, osCommand, dotGitDir, repo, configCommands, syncMutex)
statusCommands := git_commands.NewStatusCommands(gitCommon)
fileLoader := loaders.NewFileLoader(cmn, cmd, configCommands)
diff --git a/pkg/commands/git_commands/common.go b/pkg/commands/git_commands/common.go
index a045be75a..85f0d2118 100644
--- a/pkg/commands/git_commands/common.go
+++ b/pkg/commands/git_commands/common.go
@@ -1,6 +1,8 @@
package git_commands
import (
+ "sync"
+
gogit "github.com/jesseduffield/go-git/v5"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/common"
@@ -13,6 +15,8 @@ type GitCommon struct {
dotGitDir string
repo *gogit.Repository
config *ConfigCommands
+ // mutex for doing things like push/pull/fetch
+ syncMutex *sync.Mutex
}
func NewGitCommon(
@@ -22,6 +26,7 @@ func NewGitCommon(
dotGitDir string,
repo *gogit.Repository,
config *ConfigCommands,
+ syncMutex *sync.Mutex,
) *GitCommon {
return &GitCommon{
Common: cmn,
@@ -30,5 +35,6 @@ func NewGitCommon(
dotGitDir: dotGitDir,
repo: repo,
config: config,
+ syncMutex: syncMutex,
}
}
diff --git a/pkg/commands/git_commands/remote.go b/pkg/commands/git_commands/remote.go
index 3116c764a..1245a8cf0 100644
--- a/pkg/commands/git_commands/remote.go
+++ b/pkg/commands/git_commands/remote.go
@@ -40,7 +40,7 @@ func (self *RemoteCommands) UpdateRemoteUrl(remoteName string, updatedUrl string
func (self *RemoteCommands) DeleteRemoteBranch(remoteName string, branchName string) error {
command := fmt.Sprintf("git push %s --delete %s", self.cmd.Quote(remoteName), self.cmd.Quote(branchName))
- return self.cmd.New(command).PromptOnCredentialRequest().Run()
+ return self.cmd.New(command).PromptOnCredentialRequest().WithMutex(self.syncMutex).Run()
}
// CheckRemoteBranchExists Returns remote branch
diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go
index 8a6933522..fb1aa9648 100644
--- a/pkg/commands/git_commands/sync.go
+++ b/pkg/commands/git_commands/sync.go
@@ -47,7 +47,7 @@ func (self *SyncCommands) PushCmdObj(opts PushOpts) (oscommands.ICmdObj, error)
cmdStr += " " + self.cmd.Quote(opts.UpstreamBranch)
}
- cmdObj := self.cmd.New(cmdStr).PromptOnCredentialRequest()
+ cmdObj := self.cmd.New(cmdStr).PromptOnCredentialRequest().WithMutex(self.syncMutex)
return cmdObj, nil
}
@@ -83,7 +83,7 @@ func (self *SyncCommands) Fetch(opts FetchOptions) error {
} el