Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid empty author and email #5355

Merged
merged 6 commits into from
Jan 2, 2018
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/compiler/crystal/tools/init.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ module Crystal
end

def self.fetch_author
return "[your-name-here]" unless system(WHICH_GIT_COMMAND)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

`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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

`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_name = `git config --get github.name`.strip
github_name = nil if github_name.empty?
end
github_name || "your-github-here"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your-github-here -> your-github-name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

end

def self.fetch_name(opts, args)
Expand Down