pod-template
pod-template copied to clipboard
Incorrect github user name
After creating a new pod I noticed that the s.authors
field of the podspec file was incorrect:
s.authors = { '[email protected]' => '[email protected]' }
After tracing through the CocoaPods source code and now the pod-template source code, I found the issue in this file:
https://github.com/CocoaPods/pod-template/blob/633a6b7c870865f57680c3b6bb3dfb40f39eefcd/setup/TemplateConfigurator.rb
def user_name:
(ENV['GIT_COMMITTER_NAME'] || github_user_name || `git config user.name` || `<GITHUB_USERNAME>` ).strip
end
def github_user_name
github_user_name = `security find-internet-password -s github.com | grep acct | sed 's/"acct"<blob>="//g' | sed 's/"//g'`.strip
is_valid = github_user_name.empty? or github_user_name.include? '@'
return is_valid ? nil : github_user_name
end
I'll readily admit that my understanding of this code seems to be a bit confused. The is_valid
boolean seems to be checking if the username is invalid and returning nil
if the username is either blank or contains an @
. Despite the confusing variable name, the code seems fine to me at a glance. However on my machine:
- The
GIT_COMMITTER_NAME
environment variable is not set -
security find-internet-password -s github.com | grep acct | sed 's/"acct"<blob>="//g' | sed 's/"//g'
returns[email protected]
-
git config user.name
returnsSteven Barnett
-
<GITHUB_USERNAME>
is not a valid terminal command (and possibly shouldn't have been in back-ticks?)
Comparing that with the output in the podspec file, I can only surmise that github_user_name
was returned instead of git config user.name
Furthermore, even if the bug regarding returning an e-mail is resolved, I believe that git config user.name
should be favored over the security ...
solution, as this uses a username set explicitly by the developer rather than attempting to infer it