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

Incorrect github user name #235

Open
stevendesu opened this issue Jun 24, 2019 · 0 comments
Open

Incorrect github user name #235

stevendesu opened this issue Jun 24, 2019 · 0 comments

Comments

@stevendesu
Copy link

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 returns Steven 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant