Skip to content

Commit

Permalink
Avoid empty author and email (#5355)
Browse files Browse the repository at this point in the history
  • Loading branch information
faustinoaq authored and RX14 committed Jan 2, 2018
1 parent 7cad39c commit 2bff41d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/compiler/crystal/tools/init.cr
Expand Up @@ -44,20 +44,27 @@ module Crystal
end

def self.fetch_author
return "[your-name-here]" unless system(WHICH_GIT_COMMAND)
`git config --get user.name`.strip
if system(WHICH_GIT_COMMAND)
user_name = `git config --get user.name`.strip
user_name = nil if user_name.empty?
end
user_name || "your-name-here"
end

def self.fetch_email
return "[your-email-here]" unless system(WHICH_GIT_COMMAND)
`git config --get user.email`.strip
if system(WHICH_GIT_COMMAND)
user_email = `git config --get user.email`.strip
user_email = nil if user_email.empty?
end
user_email || "your-email-here"
end

def self.fetch_github_name
default = "[your-github-name]"
return default unless system(WHICH_GIT_COMMAND)
github_user = `git config --get github.user`.strip
github_user.empty? ? default : github_user
if system(WHICH_GIT_COMMAND)
github_user = `git config --get github.user`.strip
github_user = nil if github_user.empty?
end
github_user || "your-github-user"
end

def self.fetch_name(opts, args)
Expand Down

0 comments on commit 2bff41d

Please sign in to comment.