summaryrefslogtreecommitdiff
path: root/spec/bundler
diff options
context:
space:
mode:
authorDavid Rodriguez <[email protected]>2021-10-18 20:56:28 +0200
committergit <[email protected]>2024-06-06 18:44:43 +0000
commit9579c3d988fb31142700cbaa9f4c726abc0aa9e0 (patch)
tree38040cb98188fa4faeafd80e65f74ddd0851c48a /spec/bundler
parentb5a7f639615040bffde581a26ddabf80890a3493 (diff)
[rubygems/rubygems] Reuse `git` helper when possible
https://github.com/rubygems/rubygems/commit/f7c7bae940
Diffstat (limited to 'spec/bundler')
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb40
-rw-r--r--spec/bundler/cache/git_spec.rb4
-rw-r--r--spec/bundler/commands/newgem_spec.rb18
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb24
-rw-r--r--spec/bundler/support/build_metadata.rb2
-rw-r--r--spec/bundler/support/helpers.rb4
-rw-r--r--spec/bundler/support/path.rb2
-rw-r--r--spec/bundler/support/rubygems_version_manager.rb6
-rw-r--r--spec/bundler/update/git_spec.rb4
9 files changed, 52 insertions, 52 deletions
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
index 940e5df9de..187dab0e7c 100644
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ b/spec/bundler/bundler/gem_helper_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe Bundler::GemHelper do
before(:each) do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false",
"BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false"
- sys_exec("git config --global init.defaultBranch main")
+ git("config --global init.defaultBranch main")
bundle "gem #{app_name}"
prepare_gemspec(app_gemspec_path)
end
@@ -253,11 +253,11 @@ RSpec.describe Bundler::GemHelper do
end
before do
- sys_exec("git init", dir: app_path)
- sys_exec("git config user.email \"[email protected]\"", dir: app_path)
- sys_exec("git config user.name \"name\"", dir: app_path)
- sys_exec("git config commit.gpgsign false", dir: app_path)
- sys_exec("git config push.default simple", dir: app_path)
+ git("init", app_path)
+ git("config user.email \"[email protected]\"", app_path)
+ git("config user.name \"name\"", app_path)
+ git("config commit.gpgsign false", app_path)
+ git("config push.default simple", app_path)
# silence messages
allow(Bundler.ui).to receive(:confirm)
@@ -271,13 +271,13 @@ RSpec.describe Bundler::GemHelper do
end
it "when there are uncommitted files" do
- sys_exec("git add .", dir: app_path)
+ git("add .", app_path)
expect { Rake.application["release"].invoke }.
to raise_error("There are files that need to be committed first.")
end
it "when there is no git remote" do
- sys_exec("git commit -a -m \"initial commit\"", dir: app_path)
+ git("commit -a -m \"initial commit\"", app_path)
expect { Rake.application["release"].invoke }.to raise_error(RuntimeError)
end
end
@@ -286,8 +286,8 @@ RSpec.describe Bundler::GemHelper do
let(:repo) { build_git("foo", bare: true) }
before do
- sys_exec("git remote add origin #{file_uri_for(repo.path)}", dir: app_path)
- sys_exec('git commit -a -m "initial commit"', dir: app_path)
+ git("remote add origin #{file_uri_for(repo.path)}", app_path)
+ git('commit -a -m "initial commit"', app_path)
end
context "on releasing" do
@@ -296,7 +296,7 @@ RSpec.describe Bundler::GemHelper do
mock_confirm_message "Tagged v#{app_version}."
mock_confirm_message "Pushed git commits and release tag."
- sys_exec("git push -u origin main", dir: app_path)
+ git("push -u origin main", app_path)
end
it "calls rubygem_push with proper arguments" do
@@ -314,8 +314,8 @@ RSpec.describe Bundler::GemHelper do
it "also works when releasing from an ambiguous reference" do
# Create a branch with the same name as the tag
- sys_exec("git checkout -b v#{app_version}", dir: app_path)
- sys_exec("git push -u origin v#{app_version}", dir: app_path)
+ git("checkout -b v#{app_version}", app_path)
+ git("push -u origin v#{app_version}", app_path)
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
@@ -323,7 +323,7 @@ RSpec.describe Bundler::GemHelper do
end
it "also works with releasing from a branch not yet pushed" do
- sys_exec("git checkout -b module_function", dir: app_path)
+ git("checkout -b module_function", app_path)
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
@@ -337,7 +337,7 @@ RSpec.describe Bundler::GemHelper do
mock_build_message app_name, app_version
mock_confirm_message "Pushed git commits and release tag."
- sys_exec("git push -u origin main", dir: app_path)
+ git("push -u origin main", app_path)
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
end
@@ -353,7 +353,7 @@ RSpec.describe Bundler::GemHelper do
mock_confirm_message "Tag v#{app_version} has already been created."
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
- sys_exec("git tag -a -m \"Version #{app_version}\" v#{app_version}", dir: app_path)
+ git("tag -a -m \"Version #{app_version}\" v#{app_version}", app_path)
Rake.application["release"].invoke
end
@@ -374,10 +374,10 @@ RSpec.describe Bundler::GemHelper do
end
before do
- sys_exec("git init", dir: app_path)
- sys_exec("git config user.email \"[email protected]\"", dir: app_path)
- sys_exec("git config user.name \"name\"", dir: app_path)
- sys_exec("git config push.gpgsign simple", dir: app_path)
+ git("init", app_path)
+ git("config user.email \"[email protected]\"", app_path)
+ git("config user.name \"name\"", app_path)
+ git("config push.gpgsign simple", app_path)
# silence messages
allow(Bundler.ui).to receive(:confirm)
diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb
index 4b3cd4d2eb..51897ebe20 100644
--- a/spec/bundler/cache/git_spec.rb
+++ b/spec/bundler/cache/git_spec.rb
@@ -164,8 +164,8 @@ RSpec.describe "bundle cache with git" do
s.add_dependency "submodule"
end
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", dir: lib_path("has_submodule-1.0")
- sys_exec "git commit -m \"submodulator\"", dir: lib_path("has_submodule-1.0")
+ git "submodule add #{lib_path("submodule-1.0")} submodule-1.0", lib_path("has_submodule-1.0")
+ git "commit -m \"submodulator\"", lib_path("has_submodule-1.0")
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 53d0f9d6eb..9ff10158a4 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -33,9 +33,9 @@ RSpec.describe "bundle gem" do
let(:minitest_test_class_name) { "class TestMygem < Minitest::Test" }
before do
- sys_exec("git config --global user.name 'Bundler User'")
- sys_exec("git config --global user.email [email protected]")
- sys_exec("git config --global github.user bundleuser")
+ git("config --global user.name 'Bundler User'")
+ git("config --global user.email [email protected]")
+ git("config --global github.user bundleuser")
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false",
"BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false"
@@ -109,7 +109,7 @@ RSpec.describe "bundle gem" do
end
it "generates the README with a section for the Code of Conduct, respecting the configured git default branch", git: ">= 2.28.0" do
- sys_exec("git config --global init.defaultBranch main")
+ git("config --global init.defaultBranch main")
bundle "gem #{gem_name} --coc"
expect(bundled_app("#{gem_name}/README.md").read).to include("## Code of Conduct")
@@ -419,7 +419,7 @@ RSpec.describe "bundle gem" do
context "git config github.user is absent" do
before do
- sys_exec("git config --global --unset github.user")
+ git("config --global --unset github.user")
bundle "gem #{gem_name}"
end
@@ -601,8 +601,8 @@ RSpec.describe "bundle gem" do
context "git config user.{name,email} is not set" do
before do
- sys_exec("git config --global --unset user.name")
- sys_exec("git config --global --unset user.email")
+ git("config --global --unset user.name")
+ git("config --global --unset user.email")
bundle "gem #{gem_name}"
end
@@ -1317,7 +1317,7 @@ RSpec.describe "bundle gem" do
context "testing --github-username option against git and bundle config settings" do
context "without git config set" do
before do
- sys_exec("git config --global --unset github.user")
+ git("config --global --unset github.user")
end
context "with github-username option in bundle config settings set to some value" do
before do
@@ -1354,7 +1354,7 @@ RSpec.describe "bundle gem" do
context "testing github_username bundle config against git config settings" do
context "without git config set" do
before do
- sys_exec("git config --global --unset github.user")
+ git("config --global --unset github.user")
end
it_behaves_like "github_username configuration"
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index a5078e74c0..21216594b1 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -272,7 +272,7 @@ RSpec.describe "bundle install with git sources" do
s.write("lib/foo.rb", "raise 'FAIL'")
end
- sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", dir: lib_path("foo-1.0"))
+ git("update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", lib_path("foo-1.0"))
# want to ensure we don't fallback to HEAD
update_git "foo", path: lib_path("foo-1.0"), branch: "rando" do |s|
@@ -308,7 +308,7 @@ RSpec.describe "bundle install with git sources" do
s.write("lib/foo.rb", "raise 'FAIL'")
end
- sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", dir: lib_path("foo-1.0"))
+ git("update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", lib_path("foo-1.0"))
# want to ensure we don't fallback to HEAD
update_git "foo", path: lib_path("foo-1.0"), branch: "rando" do |s|
@@ -332,7 +332,7 @@ RSpec.describe "bundle install with git sources" do
end
it "does not download random non-head refs" do
- sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", dir: lib_path("foo-1.0"))
+ git("update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", lib_path("foo-1.0"))
bundle "config set global_gem_cache true"
@@ -346,7 +346,7 @@ RSpec.describe "bundle install with git sources" do
# ensure we also git fetch after cloning
bundle :update, all: true
- sys_exec("git ls-remote .", dir: Dir[home(".bundle/cache/git/foo-*")].first)
+ git("ls-remote .", Dir[home(".bundle/cache/git/foo-*")].first)
expect(out).not_to include("refs/bundler/1")
end
@@ -906,7 +906,7 @@ RSpec.describe "bundle install with git sources" do
bundle "update", all: true
expect(the_bundle).to include_gems "forced 1.1"
- sys_exec("git reset --hard HEAD^", dir: lib_path("forced-1.0"))
+ git("reset --hard HEAD^", lib_path("forced-1.0"))
bundle "update", all: true
expect(the_bundle).to include_gems "forced 1.0"
@@ -920,8 +920,8 @@ RSpec.describe "bundle install with git sources" do
build_git "has_submodule", "1.0" do |s|
s.add_dependency "submodule"
end
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", dir: lib_path("has_submodule-1.0")
- sys_exec "git commit -m \"submodulator\"", dir: lib_path("has_submodule-1.0")
+ git "submodule add #{lib_path("submodule-1.0")} submodule-1.0", lib_path("has_submodule-1.0")
+ git "commit -m \"submodulator\"", lib_path("has_submodule-1.0")
install_gemfile <<-G, raise_on_error: false
source "#{file_uri_for(gem_repo1)}"
@@ -942,8 +942,8 @@ RSpec.describe "bundle install with git sources" do
build_git "has_submodule", "1.0" do |s|
s.add_dependency "submodule"
end
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", dir: lib_path("has_submodule-1.0")
- sys_exec "git commit -m \"submodulator\"", dir: lib_path("has_submodule-1.0")
+ git "submodule add #{lib_path("submodule-1.0")} submodule-1.0", lib_path("has_submodule-1.0")
+ git "commit -m \"submodulator\"", lib_path("has_submodule-1.0")
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -962,8 +962,8 @@ RSpec.describe "bundle install with git sources" do
build_git "submodule", "1.0"
build_git "has_submodule", "1.0"
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", dir: lib_path("has_submodule-1.0")
- sys_exec "git commit -m \"submodulator\"", dir: lib_path("has_submodule-1.0")
+ git "submodule add #{lib_path("submodule-1.0")} submodule-1.0", lib_path("has_submodule-1.0")
+ git "commit -m \"submodulator\"", lib_path("has_submodule-1.0")
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
@@ -1292,7 +1292,7 @@ RSpec.describe "bundle install with git sources" do
void Init_foo() { rb_define_global_function("foo", &foo, 0); }
C
end
- sys_exec("git commit -m \"commit for iteration #{i}\" ext/foo.c", dir: git_reader.path)
+ git("commit -m \"commit for iteration #{i}\" ext/foo.c", git_reader.path)
git_commit_sha = git_reader.ref_for("HEAD")
diff --git a/spec/bundler/support/build_metadata.rb b/spec/bundler/support/build_metadata.rb
index 5898e7f3bd..189100edb7 100644
--- a/spec/bundler/support/build_metadata.rb
+++ b/spec/bundler/support/build_metadata.rb
@@ -41,7 +41,7 @@ module Spec
end
def git_commit_sha
- ruby_core_tarball? ? "unknown" : sys_exec("git rev-parse --short HEAD", dir: source_root).strip
+ ruby_core_tarball? ? "unknown" : git("rev-parse --short HEAD", source_root).strip
end
extend self
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 936a411487..0e3154c112 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -177,7 +177,7 @@ module Spec
"#{Gem.ruby} -S #{ENV["GEM_PATH"]}/bin/rake"
end
- def git(cmd, path, options = {})
+ def git(cmd, path = Dir.pwd, options = {})
sys_exec("git #{cmd}", options.merge(dir: path))
end
@@ -510,7 +510,7 @@ module Spec
end
def revision_for(path)
- sys_exec("git rev-parse HEAD", dir: path).strip
+ git("rev-parse HEAD", path).strip
end
def with_read_only(pattern)
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index 8d1bac5e03..a6dc61d15b 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -270,7 +270,7 @@ module Spec
def git_ls_files(glob)
skip "Not running on a git context, since running tests from a tarball" if ruby_core_tarball?
- sys_exec("git ls-files -z -- #{glob}", dir: source_root).split("\x0")
+ git("ls-files -z -- #{glob}", source_root).split("\x0")
end
def tracked_files_glob
diff --git a/spec/bundler/support/rubygems_version_manager.rb b/spec/bundler/support/rubygems_version_manager.rb
index 88da14b67e..70d2258e8a 100644
--- a/spec/bundler/support/rubygems_version_manager.rb
+++ b/spec/bundler/support/rubygems_version_manager.rb
@@ -65,7 +65,7 @@ class RubygemsVersionManager
def switch_local_copy_if_needed
return unless local_copy_switch_needed?
- sys_exec("git checkout #{target_tag}", dir: local_copy_path)
+ git("checkout #{target_tag}", local_copy_path)
ENV["RGV"] = local_copy_path.to_s
end
@@ -84,7 +84,7 @@ class RubygemsVersionManager
end
def local_copy_tag
- sys_exec("git rev-parse --abbrev-ref HEAD", dir: local_copy_path)
+ git("rev-parse --abbrev-ref HEAD", local_copy_path)
end
def local_copy_path
@@ -97,7 +97,7 @@ class RubygemsVersionManager
rubygems_path = source_root.join("tmp/rubygems")
unless rubygems_path.directory?
- sys_exec("git clone .. #{rubygems_path}", dir: source_root)
+ git("clone .. #{rubygems_path}", source_root)
end
rubygems_path
diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb
index 3b7bbfd979..f80281e8ce 100644
--- a/spec/bundler/update/git_spec.rb
+++ b/spec/bundler/update/git_spec.rb
@@ -142,8 +142,8 @@ RSpec.describe "bundle update" do
s.add_dependency "submodule"
end
- sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0", dir: lib_path("has_submodule-1.0")
- sys_exec "git commit -m \"submodulator\"", dir: lib_path("has_submodule-1.0")
+ git "submodule add #{lib_path("submodule-1.0")} submodule-1.0", lib_path("has_submodule-1.0")
+ git "commit -m \"submodulator\"", lib_path("has_submodule-1.0")
end
it "it unlocks the source when submodules are added to a git source" do