diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-14 08:33:27 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-14 08:33:27 +1000 |
commit | d4f4b46a1f3a0d5aa2f430be931874dedc715ee2 (patch) | |
tree | fbebb92cfd3dbc13e821659ea20dc471e6ec67f6 /pkg/commands/git.go | |
parent | f549ad0f374828728dfd206e00e56469edd56d5a (diff) |
check both local and global config for gpgsign
Diffstat (limited to 'pkg/commands/git.go')
-rw-r--r-- | pkg/commands/git.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 628b5f665..28c368be2 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -250,15 +250,27 @@ func (c *GitCommand) AbortMerge() (string, error) { return c.OSCommand.RunDirectCommand("git merge --abort") } +// UsingGpg tells us whether the user has gpg enabled so that we can know +// whether we need to run a subprocess to allow them to enter their password +func (c *GitCommand) UsingGpg() bool { + gpgsign, _ := gitconfig.Global("commit.gpgsign") + if gpgsign == "" { + gpgsign, _ = gitconfig.Local("commit.gpgsign") + } + if gpgsign == "" { + return false + } + return true +} + // Commit commit to git func (c *GitCommand) Commit(g *gocui.Gui, message string) (*exec.Cmd, error) { - command := "commit -m \"" + message + "\"" - gpgsign, _ := gitconfig.Global("commit.gpgsign") - if gpgsign != "" { - return c.OSCommand.PrepareSubProcess("git", command) + command := "git commit -m \"" + message + "\"" + if c.UsingGpg() { + return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, command) } // TODO: make these runDirectCommand functions just return an error - _, err := c.OSCommand.RunDirectCommand("git " + command) + _, err := c.OSCommand.RunDirectCommand(command) return nil, err } |