Commit ea6107f1 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #2080 from segiddins/remove-local-path-from-ticket-search-url

Try to detect and remove local paths from error messages when generating...
parents d6608d31 dedba1ad
...@@ -45,7 +45,7 @@ Repositories : #{repo_information.join("\n ")} ...@@ -45,7 +45,7 @@ Repositories : #{repo_information.join("\n ")}
#{'[!] Oh no, an error occurred.'.red} #{'[!] Oh no, an error occurred.'.red}
#{error_from_podfile(exception)} #{error_from_podfile(exception)}
#{'Search for existing github issues similar to yours:'.yellow} #{'Search for existing github issues similar to yours:'.yellow}
#{"https://github.com/CocoaPods/CocoaPods/search?q=#{CGI.escape(exception.message)}&type=Issues"} #{issues_url(exception)}
#{'If none exists, create a ticket, with the template displayed above, on:'.yellow} #{'If none exists, create a ticket, with the template displayed above, on:'.yellow}
https://github.com/CocoaPods/CocoaPods/issues/new https://github.com/CocoaPods/CocoaPods/issues/new
...@@ -57,6 +57,10 @@ EOS ...@@ -57,6 +57,10 @@ EOS
private private
def pathless_exception_message(message)
message.gsub(/- \(.*\):/, '-')
end
def markdown_podfile def markdown_podfile
return '' unless Config.instance.podfile_path && Config.instance.podfile_path.exist? return '' unless Config.instance.podfile_path && Config.instance.podfile_path.exist?
<<-EOS <<-EOS
...@@ -75,6 +79,16 @@ EOS ...@@ -75,6 +79,16 @@ EOS
end end
end end
def remove_color(string)
string.gsub(/\e\[(\d+)m/, '')
end
def issues_url(exception)
message = remove_color(pathless_exception_message(exception.message))
'https://github.com/CocoaPods/CocoaPods/search?q=' \
"#{CGI.escape(message)}&type=Issues"
end
def host_information def host_information
product, version, build =`sw_vers`.strip.split("\n").map { |line| line.split(":").last.strip } product, version, build =`sw_vers`.strip.split("\n").map { |line| line.split(":").last.strip }
"#{product} #{version} (#{build})" "#{product} #{version} (#{build})"
......
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe UserInterface::ErrorReport do
def remove_color(string)
string.gsub(/\e\[(\d+)m/, '')
end
describe 'In general' do
before do
@exception = Informative.exception('at - (~/code.rb):')
@exception.stubs(:backtrace).returns(['Line 1', 'Line 2'])
@report = UserInterface::ErrorReport
end
it 'returns a well-structured report' do
expected = <<-EOS
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack
```
CocoaPods : #{Pod::VERSION}
Ruby : #{RUBY_DESCRIPTION}
RubyGems : #{Gem::VERSION}
Host : :host_information
Xcode : :xcode_information
Ruby lib dir : #{RbConfig::CONFIG['libdir']}
Repositories : repo_1
repo_2
```
### Podfile
```ruby
```
### Error
```
Pod::Informative - [!] at - (~/code.rb):
Line 1
Line 2
```
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing github issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=%5B%21%5D+at+-&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Don't forget to anonymize any private data!
EOS
@report.stubs(:markdown_podfile).returns <<-EOS
### Podfile
```ruby
```
EOS
@report.stubs(:host_information).returns(':host_information')
@report.stubs(:xcode_information).returns(':xcode_information')
@report.stubs(:repo_information).returns(['repo_1', 'repo_2'])
report = remove_color(@report.report(@exception))
report.should == expected
end
it 'strips the local path from the exception message' do
message = @report.send(:pathless_exception_message, @exception.message)
message = remove_color(message)
message.should == '[!] at -'
end
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