diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-09 14:33:51 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-08-09 14:33:51 +1000 |
commit | 4832d365f1a2067c3bc464ec07b19f343ee4c495 (patch) | |
tree | 1b504f6120ed1a999f779923e4d587f0e67b65c8 /gitcommands.go | |
parent | bebe94b4b32e2532e80e69f83a20d9b67c9af9d2 (diff) |
use go-git for commits
Diffstat (limited to 'gitcommands.go')
-rw-r--r-- | gitcommands.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gitcommands.go b/gitcommands.go index f05e857f6..af61b22ad 100644 --- a/gitcommands.go +++ b/gitcommands.go @@ -14,6 +14,8 @@ import ( "github.com/fatih/color" "github.com/jesseduffield/gocui" gitconfig "github.com/tcnksm/go-gitconfig" + git "gopkg.in/src-d/go-git.v4" + "gopkg.in/src-d/go-git.v4/plumbing/object" ) var ( @@ -455,7 +457,19 @@ func gitCommit(g *gocui.Gui, message string) (string, error) { runSubProcess(g, "bash", "-c", "git commit -m \""+message+"\"") return "", nil } - return runDirectCommand("git commit -m \"" + message + "\"") + userName, _ := gitconfig.Global("user.name") + userEmail, _ := gitconfig.Global("user.email") + _, err := w.Commit(message, &git.CommitOptions{ + Author: &object.Signature{ + Name: userName, + Email: userEmail, + When: time.Now(), + }, + }) + if err != nil { + return err.Error(), err + } + return "", nil } func gitPull() (string, error) { |