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

[Linter] Cleanup the github sources checks #200

Merged
merged 3 commits into from
Nov 28, 2014
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 16 additions & 14 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down