From 5b23122b35d560c0585b627141db91440510bb54 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 5 Jun 2021 14:18:42 +1000 Subject: [PATCH] [v2] Make user + email discovery optional --- .../commands/initialise/initialise.go | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/v2/cmd/wails/internal/commands/initialise/initialise.go b/v2/cmd/wails/internal/commands/initialise/initialise.go index f83ca10a..2af5876b 100644 --- a/v2/cmd/wails/internal/commands/initialise/initialise.go +++ b/v2/cmd/wails/internal/commands/initialise/initialise.go @@ -107,10 +107,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error { } // Try to discover author details from git config - err := findAuthorDetails(options) - if err != nil { - return err - } + findAuthorDetails(options) return initProject(options) }) @@ -171,20 +168,18 @@ func initGit(options *templates.Options) error { return nil } -func findAuthorDetails(options *templates.Options) error { +// findAuthorDetails tries to find the user's name and email +// from gitconfig. If it finds them, it stores them in the project options +func findAuthorDetails(options *templates.Options) { if git.IsInstalled() { name, err := git.Name() - if err != nil { - return err + if err == nil { + options.AuthorName = strings.TrimSpace(name) } - options.AuthorName = strings.TrimSpace(name) email, err := git.Email() - if err != nil { - return err + if err == nil { + options.AuthorEmail = strings.TrimSpace(email) } - options.AuthorEmail = strings.TrimSpace(email) } - - return nil }