summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuanitoFatas <katehuang0320@gmail.com>2016-08-20 03:51:53 +0800
committerJuanitoFatas <katehuang0320@gmail.com>2016-08-20 03:51:53 +0800
commit7f29df5f8508b1767bb3c6ce3a849b96aa367f29 (patch)
treef7863f4c77f22239222535b4c5a3a431a9dbf036
parent54ff7a4fb827ec36d5cac2fac843993f28b19077 (diff)
downloadbundler-7f29df5f8508b1767bb3c6ce3a849b96aa367f29.tar.gz
Fill in git username to the generated github url
Most of the developers should already properly configured "git config user.name". This save time and avoid generated README.md with wrong GitHub url.
-rw-r--r--lib/bundler/cli/gem.rb3
-rw-r--r--lib/bundler/templates/newgem/README.md.tt2
-rw-r--r--spec/commands/newgem_spec.rb29
3 files changed, 32 insertions, 2 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 27f4262e30..4dc0dbdb6b 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -44,7 +44,8 @@ module Bundler
:test => options[:test],
:ext => options[:ext],
:exe => options[:exe],
- :bundler_version => bundler_dependency_version
+ :bundler_version => bundler_dependency_version,
+ :git_user_name => git_user_name.empty? ? "[USERNAME]" : git_user_name
}
ensure_safe_gem_name(name, constant_array)
diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt
index 30c7b93609..ad8d88b6e4 100644
--- a/lib/bundler/templates/newgem/README.md.tt
+++ b/lib/bundler/templates/newgem/README.md.tt
@@ -32,7 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
## Contributing
-Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.<% end %>
+Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:git_user_name] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.<% end %>
<% if config[:mit] %>
## License
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index cb3c48132a..6e80aa7a60 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -112,6 +112,35 @@ describe "bundle gem" do
end
end
+ context "README.md" do
+ let(:gem_name) { "test_gem" }
+ let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) }
+
+ context "git config user.name present" do
+ before do
+ execute_bundle_gem(gem_name)
+ end
+
+ it "contribute URL set to git username" do
+ expect(bundled_app("test_gem/README.md").read).not_to include("[USERNAME]")
+ end
+ end
+
+ context "git config user.name is absent" do
+ before do
+ `git config --unset user.name`
+ reset!
+ in_app_root
+ bundle "gem #{gem_name}"
+ remove_push_guard(gem_name)
+ end
+
+ it "contribute URL set to [USERNAME]" do
+ expect(bundled_app("test_gem/README.md").read).to include("[USERNAME]")
+ end
+ end
+ end
+
it "generates a valid gemspec" do
system_gems ["rake-10.0.2"]