Skip to content

Commit

Permalink
[rubygems/rubygems] Restore support for passing relative paths to :git
Browse files Browse the repository at this point in the history
The `file://` protocol does not really work with relative paths and it's
not necessary anyways. So restore support for that by not using
`file://`.

rubygems/rubygems@16a68998ce
  • Loading branch information
deivid-rodriguez authored and matzbot committed Aug 21, 2024
1 parent 52c0279 commit 669d1f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/bundler/source/git/git_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ def configured_uri
config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
remote.userinfo ||= config_auth
remote.to_s
elsif File.exist?(uri)
"file://#{uri}"
else
uri.to_s
end
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/allow_offline_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def break_git_remote_ops!
fetch_args = %w(fetch --force --quiet --no-tags)
clone_args = %w(clone --bare --no-hardlinks --quiet)
if (fetch_args.-(ARGV).empty? || clone_args.-(ARGV).empty?) && ARGV.any? {|arg| arg.start_with?("file://") }
if (fetch_args.-(ARGV).empty? || clone_args.-(ARGV).empty?) && File.exist?(ARGV[ARGV.index("--") + 1])
warn "git remote ops have been disabled"
exit 1
end
Expand Down
13 changes: 13 additions & 0 deletions spec/bundler/install/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
expect(the_bundle).to include_gems "foo 1.0", source: "git@#{lib_path("foo")}"
end

it "displays the revision hash of the gem repository when passed a relative local path" do
build_git "foo", "1.0", path: lib_path("foo")

relative_path = lib_path("foo").relative_path_from(bundled_app)
install_gemfile <<-G, verbose: true
source "https://gem.repo1"
gem "foo", :git => "#{relative_path}"
G

expect(out).to include("Using foo 1.0 from #{relative_path} (at main@#{revision_for(lib_path("foo"))[0..6]})")
expect(the_bundle).to include_gems "foo 1.0", source: "git@#{lib_path("foo")}"
end

it "displays the correct default branch", git: ">= 2.28.0" do
build_git "foo", "1.0", path: lib_path("foo"), default_branch: "main"

Expand Down

0 comments on commit 669d1f7

Please sign in to comment.