diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f1ed0a5..e37069134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ [Samuel Giddins](https://github.com/segiddins) [CocoaPods#2850](https://github.com/CocoaPods/CocoaPods/issues/2850) +* The Linter will now give a warning if Github Gists begin with `www` + [Joshua Kalpin](https://github.com/Kapin) + [Core#200](https://github.com/CocoaPods/Core/pull/200) + ## 0.35.0 diff --git a/lib/cocoapods-core/specification/linter.rb b/lib/cocoapods-core/specification/linter.rb index 3db219764..06a670e67 100644 --- a/lib/cocoapods-core/specification/linter.rb +++ b/lib/cocoapods-core/specification/linter.rb @@ -335,20 +335,22 @@ def perform_github_source_checks(s) if git = s[:git] return unless git =~ /^#{URI.regexp}$/ git_uri = URI.parse(git) - if git_uri.host == 'www.github.com' - results.add_warning('github_sources', 'Github repositories should ' \ - 'not use `www` in their URL.') - end - if git_uri.host == 'github.com' || git_uri.host == 'gist.github.com' - unless git.end_with?('.git') - results.add_warning('github_sources', 'Github repositories ' \ - 'should end in `.git`.') - end - unless git_uri.scheme == 'https' - results.add_warning('github_sources', 'Github repositories ' \ - 'should use an `https` link.') - end - end + perform_github_uri_checks(git, git_uri) if git_uri.host.end_with?('github.com') + end + end + + def perform_github_uri_checks(git, git_uri) + if git_uri.host.start_with?('www.') + results.add_warning('github_sources', 'Github repositories should ' \ + 'not use `www` in their URL.') + end + unless git.end_with?('.git') + results.add_warning('github_sources', 'Github repositories ' \ + 'should end in `.git`.') + end + unless git_uri.scheme == 'https' + results.add_warning('github_sources', 'Github repositories ' \ + 'should use an `https` link.') end end diff --git a/spec/specification/linter_spec.rb b/spec/specification/linter_spec.rb index e2fec7e00..f92d8e2a9 100644 --- a/spec/specification/linter_spec.rb +++ b/spec/specification/linter_spec.rb @@ -271,6 +271,11 @@ def result_should_include(*values) result_should_include('Github', 'www') end + it 'checks that Gist Github repositories do not use `www`' do + @spec.stubs(:source).returns(:git => 'https://www.gist.github.com/2823399.git', :tag => '1.0') + result_should_include('Github', 'www') + end + it 'checks that Github repositories end in .git (for compatibility)' do @spec.stubs(:source).returns(:git => 'https://github.com/repo', :tag => '1.0') result_should_include('Github', '.git')