diff options
author | Homu <homu@barosl.com> | 2016-08-02 07:27:06 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-08-02 07:27:06 +0900 |
commit | 7f82490b82680c1786bd0af7f014d7ddab07629f (patch) | |
tree | c9976e55afa11be909157042eb0b434c46822b01 | |
parent | 9dd84228ddf50af118efbc68bf341c0b1eb00e1a (diff) | |
parent | 23505779beb8694248e8c62bb049a40fd36d9290 (diff) | |
download | bundler-7f82490b82680c1786bd0af7f014d7ddab07629f.tar.gz |
Auto merge of #4795 - allenzhao:issue-4771, r=RochesterinNYC
Add message filter to generate better search URL
Fixes #4771
/c @RochesterinNYC @segiddins
-rw-r--r-- | lib/bundler/friendly_errors.rb | 4 | ||||
-rw-r--r-- | spec/bundler/friendly_errors_spec.rb | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index b6c22ee60e..df45dd6946 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -89,8 +89,10 @@ module Bundler end def issues_url(exception) + message = exception.message.lines.first.tr(":", " ").chomp + message = message.split("-").first if exception.is_a?(Errno) "https://github.com/bundler/bundler/search?q=" \ - "#{CGI.escape(exception.message.lines.first.chomp)}&type=Issues" + "#{CGI.escape(message)}&type=Issues" end end diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index ae197a4bab..cc478ef7a5 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -2,6 +2,7 @@ require "spec_helper" require "bundler" require "bundler/friendly_errors" +require "cgi" describe Bundler, "friendly errors" do context "with invalid YAML in .gemrc" do @@ -66,5 +67,24 @@ END expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=First+line+of+the+exception+message&type=Issues") end + + it "generates the url without colons" do + exception = Exception.new(<<END) +Exception ::: with ::: colons ::: +END + issues_url = Bundler::FriendlyErrors.issues_url(exception) + expect(issues_url).not_to include("%3A") + expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Exception with colons ")}&type=Issues") + end + + it "removes information after - for Errono::EACCES" do + exception = Exception.new(<<END) +Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/foo/bar/ +END + allow(exception).to receive(:is_a?).with(Errno).and_return(true) + issues_url = Bundler::FriendlyErrors.issues_url(exception) + expect(issues_url).not_to include("/Users/foo/bar") + expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Errno EACCES Permission denied @ dir_s_mkdir ")}&type=Issues") + end end end |