|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | RSpec.describe "bundle lock with git gems" do |
4 | | - before :each do |
| 4 | + let(:install_gemfile_with_foo_as_a_git_dependency) do |
5 | 5 | build_git "foo" |
6 | 6 |
|
7 | 7 | install_gemfile <<-G |
|
11 | 11 | end |
12 | 12 |
|
13 | 13 | it "doesn't break right after running lock" do |
| 14 | + install_gemfile_with_foo_as_a_git_dependency |
| 15 | + |
14 | 16 | expect(the_bundle).to include_gems "foo 1.0.0" |
15 | 17 | end |
16 | 18 |
|
17 | 19 | it "doesn't print errors even if running lock after removing the cache" do |
| 20 | + install_gemfile_with_foo_as_a_git_dependency |
| 21 | + |
18 | 22 | FileUtils.rm_rf(Dir[default_cache_path("git/foo-1.0-*")].first) |
19 | 23 |
|
20 | 24 | bundle "lock --verbose" |
|
23 | 27 | end |
24 | 28 |
|
25 | 29 | it "prints a proper error when changing a locked Gemfile to point to a bad branch" do |
| 30 | + install_gemfile_with_foo_as_a_git_dependency |
| 31 | + |
26 | 32 | gemfile <<-G |
27 | 33 | source "https://gem.repo1" |
28 | 34 | gem 'foo', :git => "#{lib_path("foo-1.0")}", :branch => "bad" |
|
34 | 40 | end |
35 | 41 |
|
36 | 42 | it "prints a proper error when installing a Gemfile with a locked ref that does not exist" do |
| 43 | + install_gemfile_with_foo_as_a_git_dependency |
| 44 | + |
37 | 45 | lockfile <<~L |
38 | 46 | GIT |
39 | 47 | remote: #{lib_path("foo-1.0")} |
|
61 | 69 | end |
62 | 70 |
|
63 | 71 | it "locks a git source to the current ref" do |
| 72 | + install_gemfile_with_foo_as_a_git_dependency |
| 73 | + |
64 | 74 | update_git "foo" |
65 | 75 | bundle :install |
66 | 76 |
|
|
73 | 83 | end |
74 | 84 |
|
75 | 85 | it "properly clones a git source locked to an out of date ref" do |
| 86 | + install_gemfile_with_foo_as_a_git_dependency |
| 87 | + |
76 | 88 | update_git "foo" |
77 | 89 |
|
78 | 90 | bundle :install, env: { "BUNDLE_PATH" => "foo" } |
79 | 91 | expect(err).to be_empty |
80 | 92 | end |
81 | 93 |
|
82 | 94 | it "properly fetches a git source locked to an unreachable ref" do |
| 95 | + install_gemfile_with_foo_as_a_git_dependency |
| 96 | + |
83 | 97 | # Create a commit and make it unreachable |
84 | 98 | git "checkout -b foo ", lib_path("foo-1.0") |
85 | 99 | unreachable_sha = update_git("foo").ref_for("HEAD") |
|
118 | 132 | end |
119 | 133 |
|
120 | 134 | it "properly fetches a git source locked to an annotated tag" do |
| 135 | + install_gemfile_with_foo_as_a_git_dependency |
| 136 | + |
121 | 137 | # Create an annotated tag |
122 | 138 | git("tag -a v1.0 -m 'Annotated v1.0'", lib_path("foo-1.0")) |
123 | 139 | annotated_tag = git("rev-parse v1.0", lib_path("foo-1.0")) |
|
154 | 170 | end |
155 | 171 |
|
156 | 172 | it "provides correct #full_gem_path" do |
| 173 | + install_gemfile_with_foo_as_a_git_dependency |
| 174 | + |
157 | 175 | run <<-RUBY |
158 | 176 | puts Bundler.rubygems.find_name('foo').first.full_gem_path |
159 | 177 | RUBY |
160 | 178 | expect(out).to eq(bundle("info foo --path")) |
161 | 179 | end |
| 180 | + |
| 181 | + it "does not lock versions that don't exist in the repository when changing a GEM transitive dep to a GIT direct dep" do |
| 182 | + build_repo4 do |
| 183 | + build_gem "activesupport", "8.0.0" do |s| |
| 184 | + s.add_dependency "securerandom" |
| 185 | + end |
| 186 | + |
| 187 | + build_gem "securerandom", "0.3.1" |
| 188 | + end |
| 189 | + |
| 190 | + path = lib_path("securerandom") |
| 191 | + |
| 192 | + build_git "securerandom", "0.3.2", path: path |
| 193 | + |
| 194 | + lockfile <<~L |
| 195 | + GEM |
| 196 | + remote: https://gem.repo4/ |
| 197 | + specs: |
| 198 | + activesupport (8.0.0) |
| 199 | + securerandom |
| 200 | + securerandom (0.3.1) |
| 201 | +
|
| 202 | + PLATFORMS |
| 203 | + #{lockfile_platforms} |
| 204 | +
|
| 205 | + DEPENDENCIES |
| 206 | + activesupport |
| 207 | +
|
| 208 | + BUNDLED WITH |
| 209 | + #{Bundler::VERSION} |
| 210 | + L |
| 211 | + |
| 212 | + gemfile <<~G |
| 213 | + source "https://gem.repo4" |
| 214 | +
|
| 215 | + gem "activesupport" |
| 216 | + gem "securerandom", git: "#{path}" |
| 217 | + G |
| 218 | + |
| 219 | + bundle "lock" |
| 220 | + |
| 221 | + expect(lockfile).to include("securerandom (0.3.2)") |
| 222 | + end |
162 | 223 | end |
0 commit comments