From e64bbab4830b3b6ef3cb7105165b923b163fab3d Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Tue, 29 Nov 2016 19:17:06 -0600 Subject: [Env] Print as GFM --- lib/bundler/env.rb | 45 +++++++++++++++++++++++++-------------------- spec/bundler/env_spec.rb | 6 +++--- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index f7c6f7e83d..8eea663bfa 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -12,44 +12,49 @@ module Bundler print_gemfile = options.delete(:print_gemfile) print_gemspecs = options.delete(:print_gemspecs) - out = String.new("Environment\n\n") - out << " Bundler #{Bundler::VERSION}\n" - out << " Rubygems #{Gem::VERSION}\n" - out << " Ruby #{ruby_version}" - out << " GEM_HOME #{ENV["GEM_HOME"]}\n" unless ENV["GEM_HOME"].nil? || ENV["GEM_HOME"].empty? - out << " GEM_PATH #{ENV["GEM_PATH"]}\n" unless ENV["GEM_PATH"] == ENV["GEM_HOME"] - out << " RVM #{ENV["rvm_version"]}\n" if ENV["rvm_version"] - out << " Git #{git_version}\n" - out << " Platform #{Gem::Platform.local}\n" - out << " OpenSSL #{OpenSSL::OPENSSL_VERSION}\n" if defined?(OpenSSL::OPENSSL_VERSION) + out = String.new("## Environment\n\n```\n") + out << "Bundler #{Bundler::VERSION}\n" + out << "Rubygems #{Gem::VERSION}\n" + out << "Ruby #{ruby_version}" + out << "GEM_HOME #{ENV["GEM_HOME"]}\n" unless ENV["GEM_HOME"].nil? || ENV["GEM_HOME"].empty? + out << "GEM_PATH #{ENV["GEM_PATH"]}\n" unless ENV["GEM_PATH"] == ENV["GEM_HOME"] + out << "RVM #{ENV["rvm_version"]}\n" if ENV["rvm_version"] + out << "Git #{git_version}\n" + out << "Platform #{Gem::Platform.local}\n" + out << "OpenSSL #{OpenSSL::OPENSSL_VERSION}\n" if defined?(OpenSSL::OPENSSL_VERSION) %w(rubygems-bundler open_gem).each do |name| specs = Bundler.rubygems.find_name(name) - out << " #{name} (#{specs.map(&:version).join(",")})\n" unless specs.empty? + out << "#{name} (#{specs.map(&:version).join(",")})\n" unless specs.empty? end - out << "\nBundler settings\n\n" unless Bundler.settings.all.empty? + out << "```\n" + + out << "\n## Bundler settings\n\n```\n" unless Bundler.settings.all.empty? Bundler.settings.all.each do |setting| - out << " " << setting << "\n" + out << setting << "\n" Bundler.settings.pretty_values_for(setting).each do |line| - out << " " << line << "\n" + out << " " << line << "\n" end end + out << "```\n" return out unless SharedHelpers.in_bundle? if print_gemfile - out << "\n#{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)}\n\n" - out << " " << read_file(Bundler.default_gemfile).gsub(/\n/, "\n ") << "\n" + out << "## Gemfile\n" + out << "\n### `#{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)}`\n\n" + out << "```ruby\n" << read_file(Bundler.default_gemfile).chomp << "\n```\n" - out << "\n#{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}\n\n" - out << " " << read_file(Bundler.default_lockfile).gsub(/\n/, "\n ") << "\n" + out << "\n### `#{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}`\n\n" + out << "```\n" << read_file(Bundler.default_lockfile).chomp << "\n```\n" end if print_gemspecs dsl = Dsl.new.tap {|d| d.eval_gemfile(Bundler.default_gemfile) } + out << "\n## Gemspecs\n" unless dsl.gemspecs.empty? dsl.gemspecs.each do |gs| - out << "\n#{File.basename(gs.loaded_from)}" - out << "\n\n " << read_file(gs.loaded_from).gsub(/\n/, "\n ") << "\n" + out << "\n### `#{File.basename(gs.loaded_from)}`" + out << "\n\n```ruby\n" << read_file(gs.loaded_from).chomp << "\n```\n" end end diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb index 245073d9b8..f2cf26c4cf 100644 --- a/spec/bundler/env_spec.rb +++ b/spec/bundler/env_spec.rb @@ -53,13 +53,13 @@ describe Bundler::Env do let(:output) { env.report(:print_gemfile => true) } it "prints the environment" do - expect(output).to start_with("Environment") + expect(output).to start_with("## Environment") end end context "when Gemfile contains a gemspec and print_gemspecs is true" do let(:gemspec) do - <<-GEMSPEC.gsub(/^\s+/, "") + strip_whitespace(<<-GEMSPEC) Gem::Specification.new do |gem| gem.name = "foo" gem.author = "Fumofu" @@ -76,7 +76,7 @@ describe Bundler::Env do end it "prints the gemspec" do - output = env.report(:print_gemspecs => true).gsub(/^\s+/, "") + output = env.report(:print_gemspecs => true) expect(output).to include("foo.gemspec") expect(output).to include(gemspec) -- cgit v1.2.1 From 4d6a5cbf1ca2648896d696ab97bc366cf07c7b01 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Tue, 29 Nov 2016 19:32:56 -0600 Subject: [FriendlyErrors] Use GFM in issue report template --- lib/bundler/env.rb | 2 +- lib/bundler/friendly_errors.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index 8eea663bfa..0b51c6c4a4 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -41,7 +41,7 @@ module Bundler return out unless SharedHelpers.in_bundle? if print_gemfile - out << "## Gemfile\n" + out << "\n## Gemfile\n" out << "\n### `#{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)}`\n\n" out << "```ruby\n" << read_file(Bundler.default_gemfile).chomp << "\n```\n" diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index c2853294a7..911c08f714 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -71,12 +71,14 @@ module Bundler Instead, what happened was... - Error details + ## Backtrace - #{e.class}: #{e.message} - #{e.backtrace && e.backtrace.join("\n ")} + ``` + #{e.class}: #{e.message} + #{e.backtrace && e.backtrace.join("\n ").chomp} + ``` - #{Bundler::Env.new.report(:print_gemfile => false, :print_gemspecs => false).gsub(/\n/, "\n ").strip} + #{Bundler::Env.new.report(:print_gemfile => false, :print_gemspecs => false)} --- TEMPLATE END ---------------------------------------------------------------- EOS -- cgit v1.2.1 From 926a79e2b376f304a5a8928385b81e5955482456 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Wed, 30 Nov 2016 15:48:02 -0600 Subject: [FriendlyErrors] Prettify, taking into account formatting suggestions --- lib/bundler/env.rb | 6 +++--- lib/bundler/friendly_errors.rb | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index 0b51c6c4a4..7e9bcc2866 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -42,10 +42,10 @@ module Bundler if print_gemfile out << "\n## Gemfile\n" - out << "\n### `#{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)}`\n\n" + out << "\n### #{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)}\n\n" out << "```ruby\n" << read_file(Bundler.default_gemfile).chomp << "\n```\n" - out << "\n### `#{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}`\n\n" + out << "\n### #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}\n\n" out << "```\n" << read_file(Bundler.default_lockfile).chomp << "\n```\n" end @@ -53,7 +53,7 @@ module Bundler dsl = Dsl.new.tap {|d| d.eval_gemfile(Bundler.default_gemfile) } out << "\n## Gemspecs\n" unless dsl.gemspecs.empty? dsl.gemspecs.each do |gs| - out << "\n### `#{File.basename(gs.loaded_from)}`" + out << "\n### #{File.basename(gs.loaded_from)}" out << "\n\n```ruby\n" << read_file(gs.loaded_from).chomp << "\n```\n" end end diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index 911c08f714..3a46473448 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -58,18 +58,32 @@ module Bundler def request_issue_report_for(e) Bundler.ui.info <<-EOS.gsub(/^ {8}/, "") --- ERROR REPORT TEMPLATE ------------------------------------------------------- - - What did you do? + # Error Report + + ## Questions + + Please fill out answers to these questions, it'll help us figure out + why things are going wrong. + + - **What did you do?** I ran the command `#{$PROGRAM_NAME} #{ARGV.join(" ")}` - - What did you expect to happen? + - **What did you expect to happen?** I expected Bundler to... - - What happened instead? + - **What happened instead?** Instead, what happened was... + - **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?** + + I tried... + + - **Have you read our issues document, https://github.com/bundler/bundler/blob/master/ISSUES.md?** + + ... ## Backtrace -- cgit v1.2.1