Unverified Commit f4f115c8 authored by Orta Therox's avatar Orta Therox Committed by Samuel Giddins

[GH Inspector] Add CHANGELOG and fix rubocop/inch issues

parent b4d58574
......@@ -40,6 +40,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Danielle Tomlinson](https://github.com/dantoml)
[#5517](https://github.com/CocoaPods/CocoaPods/issues/5517)
* Show GitHub Issues that could be related to exceptions.
[Orta Therox](https://github.com/orta)
[#4817](https://github.com/CocoaPods/CocoaPods/issues/4817)
* Improve handling of app extensions, watch os 1 extensions
and framework targets
[benasher44](https://github.com/benasher44)
......
......@@ -107,14 +107,9 @@ PATH
cocoapods-try (>= 1.0.0, < 2.0)
colored (~> 1.2)
escape (~> 0.0.4)
<<<<<<< HEAD
fourflusher (~> 1.0.1)
=======
fourflusher (~> 0.3.0)
gh_inspector (~> 1.0)
>>>>>>> e3c6df0... Update to use the latest GHInspector
molinillo (~> 0.5.0)
gh-issues-inspector (~> 0.5.0)
nap (~> 1.0)
xcodeproj (>= 1.1.0, < 2.0)
......
......@@ -112,9 +112,9 @@ EOS
```
EOS
end
def search_for_exceptions(exception)
inspector = GhInspector::Inspector.new "cocoapods", "cocoapods"
inspector = GhInspector::Inspector.new 'cocoapods', 'cocoapods'
message_delegate = UserInterface::InspectorReporter.new
inspector.search_exception exception, message_delegate
end
......
......@@ -6,12 +6,31 @@ module Pod
#
class InspectorReporter
# Called just as the investigation has begun.
def inspector_started_query(query, inspector)
# Lets the user know that it's looking for an issue.
#
# @param [query] String unused
#
# @param [GhInspector::Inspector] inspector
# The current inspector
#
# @return [void]
#
def inspector_started_query(_, inspector)
UI.puts "Looking for related issues on #{inspector.repo_owner}/#{inspector.repo_name}..."
end
# Called once the inspector has recieved a report with more than one issue.
def inspector_successfully_recieved_report(report, inspector)
# Called once the inspector has recieved a report with more than one issue,
# showing the top 3 issues, and offering a link to see more.
#
# @param [GhInspector::InspectionReport] report
# Report a list of the issues
#
# @param [GhInspector::Inspector] inspector
# The current inspector
#
# @return [void]
#
def inspector_successfully_recieved_report(report, _)
report.issues[0..2].each { |issue| print_issue_full(issue) }
if report.issues.count > 3
......@@ -21,15 +40,36 @@ module Pod
end
# Called once the report has been recieved, but when there are no issues found.
def inspector_recieved_empty_report(report, inspector)
UI.puts "Found no similar issues. To create a new issue, please visit:"
#
# @param [GhInspector::InspectionReport] report
# An empty report
#
# @param [GhInspector::Inspector] inspector
# The current inspector
#
# @return [void]
#
def inspector_recieved_empty_report(_, inspector)
UI.puts 'Found no similar issues. To create a new issue, please visit:'
UI.puts "https://github.com/#{inspector.repo_owner}/#{inspector.repo_name}/issues/new"
end
# Called when there have been networking issues in creating the report.
#
# @param [Error] error
# The error returned during networking
#
# @param [String] query
# The original search query
#
# @param [GhInspector::Inspector] inspector
# The current inspector
#
# @return [void]
#
def inspector_could_not_create_report(error, query, inspector)
safe_query = URI.escape query
UI.puts "Could not access the GitHub API, you may have better luck via the website."
UI.puts 'Could not access the GitHub API, you may have better luck via the website.'
UI.puts "https://github.com/#{inspector.repo_owner}/#{inspector.repo_name}/search?q=#{safe_query}&type=Issues&utf8=✓"
UI.puts "Error: #{error.name}"
end
......@@ -41,9 +81,9 @@ module Pod
UI.puts " - #{issue.title}"
UI.puts " #{safe_url} [#{issue.state}] [#{issue.comments} comment#{issue.comments == 1 ? '' : 's'}]"
UI.puts " #{pretty_date(issue.updated_at)}"
UI.puts ""
UI.puts ''
end
# Taken from http://stackoverflow.com/questions/195740/how-do-you-do-relative-time-in-rails
def pretty_date(date_string)
date = Time.parse(date_string)
......@@ -61,10 +101,9 @@ module Pod
when 172_001..518_400 then ((a + 800) / (60 * 60 * 24)).to_i.to_s + ' days ago'
when 518_400..1_036_800 then 'a week ago'
when 1_036_801..4_147_204 then ((a + 180_000) / (60 * 60 * 24 * 7)).to_i.to_s + ' weeks ago'
else date.strftime("%d %b %Y")
else date.strftime('%d %b %Y')
end
end
end
end
end
......@@ -110,16 +110,16 @@ EOS
message = remove_color(message)
message.should == '[!] at -'
end
it "handles inspector_successfully_recieved_report" do
it 'handles inspector_successfully_recieved_report' do
time = Time.new(2016, 5, 13)
Time.stubs(:now).returns(time)
url = 'https://api.github.com/search/issues?q=Testing+repo:cocoapods/cocoapods'
fixture_json_text = File.read SpecHelper.fixture("github_search_response.json")
fixture_json_text = File.read SpecHelper.fixture('github_search_response.json')
GhInspector::Sidekick.any_instance.expects(:get_api_results).with(url).returns(JSON.parse(fixture_json_text))
error = NameError.new("Testing", "orta")
error = NameError.new('Testing', 'orta')
@report.search_for_exceptions error
result = <<-EOS
Looking for related issues on cocoapods/cocoapods...
......@@ -140,7 +140,6 @@ https://github.com/cocoapods/cocoapods/search?q=Testing&type=Issues&utf8=✓
EOS
UI.output.should == result
end
end
end
end
......@@ -16,30 +16,28 @@ end
module Pod
describe UserInterface::InspectorReporter do
it "handles inspector_started_query" do
inspector = GhInspector::Inspector.new "cocoapods", "cocoapods"
it 'handles inspector_started_query' do
inspector = GhInspector::Inspector.new 'cocoapods', 'cocoapods'
reporter = UserInterface::InspectorReporter.new
reporter.inspector_started_query("query", inspector)
UI.output.should.match /Looking for related issues on cocoapods\/cocoapods/
reporter.inspector_started_query('query', inspector)
UI.output.should.match %r{Looking for related issues on cocoapods\/cocoapods}
end
it "handles inspector_successfully_recieved_report" do
it 'handles inspector_successfully_recieved_report' do
url = 'https://api.github.com/search/issues?q=Testing+repo:cocoapods/cocoapods'
fixture_json_text = File.read SpecHelper.fixture("github_search_response.json")
fixture_json_text = File.read SpecHelper.fixture('github_search_response.json')
GhInspector::Sidekick.any_instance.expects(:get_api_results).with(url).returns(JSON.parse(fixture_json_text))
inspector = GhInspector::Inspector.new "cocoapods", "cocoapods"
inspector = GhInspector::Inspector.new 'cocoapods', 'cocoapods'
report = inspector.search_query 'Testing', SilentEvidence.new
reporter = UserInterface::InspectorReporter.new
reporter.inspector_successfully_recieved_report(report, inspector)
UI.output.should.match /Travis CI with Ruby 1.9.x fails for recent pull requests/
UI.output.should.match /https:\/\/github.com\/CocoaPods\/CocoaPods\/issues\/646 \[closed\] \[8 comments\]/
UI.output.should.match %r{https:\/\/github.com\/CocoaPods\/CocoaPods\/issues\/646 \[closed\] \[8 comments\]}
UI.output.should.match /pod search --full chokes on cocos2d.podspec/
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment