mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-09 09:22:48 +03:00
Fix wrong ff-only configuration
This commit is contained in:
committed by
Jesse Duffield
parent
c57a0077d0
commit
b4e6850f98
@@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Push pushes to a branch
|
// Push pushes to a branch
|
||||||
@@ -59,3 +60,32 @@ func (c *GitCommand) FetchRemote(remoteName string, promptUserForCredential func
|
|||||||
command := fmt.Sprintf("git fetch %s", remoteName)
|
command := fmt.Sprintf("git fetch %s", remoteName)
|
||||||
return c.OSCommand.DetectUnamePass(command, promptUserForCredential)
|
return c.OSCommand.DetectUnamePass(command, promptUserForCredential)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *GitCommand) GetPullMode(mode string) string {
|
||||||
|
if mode != "auto" {
|
||||||
|
return mode
|
||||||
|
}
|
||||||
|
|
||||||
|
var isRebase bool
|
||||||
|
var isFf bool
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
|
wg.Add(2)
|
||||||
|
go func() {
|
||||||
|
isRebase = c.GetConfigValue("pull.rebase") == "true"
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
go func() {
|
||||||
|
isFf = c.GetConfigValue("pull.ff") == "only"
|
||||||
|
wg.Done()
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
if isRebase {
|
||||||
|
return "rebase"
|
||||||
|
} else if isFf {
|
||||||
|
return "ff-only"
|
||||||
|
} else {
|
||||||
|
return "merge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
@@ -660,42 +659,15 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mode := gui.getPullMode()
|
mode := &gui.Config.GetUserConfig().Git.Pull.Mode
|
||||||
|
*mode = gui.GitCommand.GetPullMode(*mode)
|
||||||
|
|
||||||
// TODO: this doesn't look like a good idea. Why the goroutine?
|
// TODO: this doesn't look like a good idea. Why the goroutine?
|
||||||
go utils.Safe(func() { _ = gui.pullWithMode(mode, opts) })
|
go utils.Safe(func() { _ = gui.pullWithMode(*mode, opts) })
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getPullMode() string {
|
|
||||||
mode := &gui.Config.GetUserConfig().Git.Pull.Mode
|
|
||||||
if *mode == "auto" {
|
|
||||||
var isRebase bool
|
|
||||||
var isFf bool
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
wg.Add(2)
|
|
||||||
go func() {
|
|
||||||
isRebase = gui.GitCommand.GetConfigValue("pull.rebase") == "true"
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
go func() {
|
|
||||||
isFf = gui.GitCommand.GetConfigValue("pull.ff") == "true"
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
if isRebase {
|
|
||||||
*mode = "rebase"
|
|
||||||
} else if isFf {
|
|
||||||
*mode = "ff-only"
|
|
||||||
} else {
|
|
||||||
*mode = "merge"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *mode
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
||||||
gui.Mutexes.FetchMutex.Lock()
|
gui.Mutexes.FetchMutex.Lock()
|
||||||
defer gui.Mutexes.FetchMutex.Unlock()
|
defer gui.Mutexes.FetchMutex.Unlock()
|
||||||
|
Reference in New Issue
Block a user