Skip to content

Commit a459b1b

Browse files
committed
fix(auth): Fix author info for names with spaces
Fix author info for names with spaces Signed-off-by: Dries De Peuter <[email protected]>
1 parent 10f575b commit a459b1b

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

git_wapper.go

+8-13
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,20 @@ func createSOB() (string, error) {
100100
if err != nil {
101101
return "", err
102102
}
103-
return fmt.Sprintf("Signed-off-by: %s %s", name, email), nil
103+
return fmt.Sprintf("Signed-off-by: %s <%s>", name, email), nil
104104
}
105105

106106
func gitAuthor() (string, string, error) {
107-
name := "Undefined"
108-
email := "Undefined"
107+
name := ""
108+
email := ""
109109

110-
msg, err := git("var", "GIT_AUTHOR_IDENT")
111-
if err != nil {
112-
return "", "", err
113-
}
114-
115-
authorInfo := strings.Fields(msg)
116-
if len(authorInfo) > 1 && authorInfo[0] != "" {
117-
name = authorInfo[0]
110+
if cfg, err := git("config", "user.name"); err == nil {
111+
name = cfg
118112
}
119-
if len(authorInfo) > 2 && authorInfo[1] != "" {
120-
email = authorInfo[1]
113+
if cfg, err := git("config", "user.email"); err == nil {
114+
email = cfg
121115
}
116+
122117
return name, email, nil
123118
}
124119

0 commit comments

Comments
 (0)