diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-16 14:46:53 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | 1dd7307fde033dae5fececac15810a99e26c3d91 (patch) | |
tree | 4e851c9e3229a6fe3b4191f6311d05d7a9142960 /pkg | |
parent | a90b6efded49abcfa2516db794d7875b0396f558 (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')
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 |