1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

throw error when git username not configured

This commit is contained in:
Jesse Duffield
2018-08-09 15:24:12 +10:00
parent f33b2b2277
commit 5f70b2d9cd
2 changed files with 19 additions and 13 deletions

View File

@ -457,9 +457,12 @@ func gitCommit(g *gocui.Gui, message string) (string, error) {
runSubProcess(g, "bash", "-c", "git commit -m \""+message+"\"")
return "", nil
}
userName, _ := gitconfig.Global("user.name")
userEmail, _ := gitconfig.Global("user.email")
_, err := w.Commit(message, &git.CommitOptions{
userName, err := gitconfig.Username()
if userName == "" {
return "", errNoUsername
}
userEmail, err := gitconfig.Email()
_, err = w.Commit(message, &git.CommitOptions{
Author: &object.Signature{
Name: userName,
Email: userEmail,