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

defensive coding in case github isn't set in .gitconfig file #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions lib/gem_init/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class App
:email => "YOUR EMAIL",
},
:github => {
:name => "your_github_user_name"
:user => "your_github_user_name"
}
}

Expand Down Expand Up @@ -54,7 +54,8 @@ def email
end

def github_user
@github_user ||= git_config[:github][:user]
config = git_config[:github] || DEFAULT_GIT_CONFIG[:github]
@github_user ||= config[:user]
end

private
Expand All @@ -76,7 +77,9 @@ def read_git_config
end
end
# Be a tad paranoid and make it harder to accidentally reveal this
config[:github][:token] = nil
if config[:github]
config[:github][:token] = nil
end
config
rescue Errno::ENOENT
warn "Could not read your ~/.gitconfig, using silly defaults."
Expand Down
2 changes: 1 addition & 1 deletion lib/gem_init/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module GemInit
module Version
MAJOR = 0
MINOR = 0
TINY = 1
TINY = 2
BUILD = nil
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
end
Expand Down