diff options
author | Emiliano Ruiz Carletti <contact@eruizc.dev> | 2021-04-22 09:28:40 -0300 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-15 08:31:07 +1000 |
commit | b4e6850f98987d23a0211cb5b9b91d173c1e7210 (patch) | |
tree | 111eb0f851e07fd1e5dfe5a2f9496aa0452276f3 /pkg/commands/sync.go | |
parent | c57a0077d043bc0ecd3f4c8e0988c46655eecb94 (diff) |
Fix wrong ff-only configuration
Diffstat (limited to 'pkg/commands/sync.go')
-rw-r--r-- | pkg/commands/sync.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/commands/sync.go b/pkg/commands/sync.go index e3be30dc1..e032d0a65 100644 --- a/pkg/commands/sync.go +++ b/pkg/commands/sync.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "sync" ) // Push pushes to a branch @@ -59,3 +60,32 @@ func (c *GitCommand) FetchRemote(remoteName string, promptUserForCredential func command := fmt.Sprintf("git fetch %s", remoteName) 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" + } +} |