Skip to content

Commit

Permalink
Merge pull request #200 from CocoaPods/cleanup-github-checks
Browse files Browse the repository at this point in the history
[Linter] Cleanup the github sources checks
  • Loading branch information
segiddins committed Nov 28, 2014
2 parents 49a91ac + 6121197 commit 8c0ae56
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
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

0 comments on commit 8c0ae56

Please sign in to comment.