gem_kit-release 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gem_kit/release/commands/bump.rb +69 -0
- data/lib/gem_kit/release/project.rb +47 -0
- data/lib/gem_kit/release/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbdaca4c93bb73c92daa2e585aa8f6dbcef18a7717a6f9c3549f943272b13947
|
|
4
|
+
data.tar.gz: 8d41aaa5cd762b8c6660d6cffbb669d1d17ce5a604ea578d1673681eb6c39809
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e431cf45975cc92e084d02988ed88a68053bf538f386bf734a167a9e0a6914de609a8d22555ba4e238c41ff6ae932bbfa44e5933fd665f19b0c4468336d60e8b
|
|
7
|
+
data.tar.gz: 852b384995fbbd1ee34b28200cdcd472eddb6c3460e99101b70df56da4435b45be91fc6805959f21eb942bfc7287f883000e70e1566f684e518102727a29f1d1
|
|
@@ -35,6 +35,8 @@ module GemKit
|
|
|
35
35
|
version_file.write(target)
|
|
36
36
|
say("#{current} -> #{target}")
|
|
37
37
|
|
|
38
|
+
relock(target)
|
|
39
|
+
|
|
38
40
|
upcoming = gate.upcoming_deprecations(target)
|
|
39
41
|
unless upcoming.empty?
|
|
40
42
|
say("#{upcoming.size} deprecation(s) still outstanding (none due in #{target}).")
|
|
@@ -45,6 +47,35 @@ module GemKit
|
|
|
45
47
|
say
|
|
46
48
|
say("#{RED}now run: gem kit changelog --write#{RESET}")
|
|
47
49
|
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
# A Gemfile that says `gemspec` or `path: "."` records this gem's own
|
|
54
|
+
# version in Gemfile.lock, so a bump that only rewrites the version
|
|
55
|
+
# file leaves the two disagreeing — and bundler refuses outright
|
|
56
|
+
# under frozen mode, which is what bundlerEnv sets. Relock, so the
|
|
57
|
+
# bump is one coherent change rather than a trap for the next
|
|
58
|
+
# command anyone runs.
|
|
59
|
+
#
|
|
60
|
+
# `bundle lock` rather than `bundle install`: nothing needs
|
|
61
|
+
# installing, only the lockfile needs to agree.
|
|
62
|
+
def relock(target)
|
|
63
|
+
return unless project.self_locked?
|
|
64
|
+
|
|
65
|
+
say("Relocking #{File.basename(project.lockfile_path)}…")
|
|
66
|
+
|
|
67
|
+
ok = Dir.chdir(project.root) do
|
|
68
|
+
# BUNDLE_FROZEN is exactly what stops this, and inheriting it
|
|
69
|
+
# from an ambient devshell would defeat the point.
|
|
70
|
+
system({"BUNDLE_FROZEN" => "false", "BUNDLE_GEMFILE" => nil},
|
|
71
|
+
"bundle", "lock", out: File::NULL, err: File::NULL)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
return if ok
|
|
75
|
+
|
|
76
|
+
say("#{RED}could not relock — run `bundle lock` before committing " \
|
|
77
|
+
"#{target}#{RESET}")
|
|
78
|
+
end
|
|
48
79
|
end
|
|
49
80
|
end
|
|
50
81
|
end
|
|
@@ -95,6 +126,44 @@ describe "gem_kit/release/commands/bump" do
|
|
|
95
126
|
end
|
|
96
127
|
end
|
|
97
128
|
|
|
129
|
+
# The version lives in two files when a gem is in its own bundle, and a bump
|
|
130
|
+
# that moves one of them leaves bundler refusing to do anything.
|
|
131
|
+
it "relocks a lockfile that records this gem's own version" do
|
|
132
|
+
with_gem do |dir|
|
|
133
|
+
File.write(File.join(dir, "Gemfile"), %(source "https://rubygems.org"\ngemspec\n))
|
|
134
|
+
File.write(File.join(dir, "Gemfile.lock"), <<~LOCK)
|
|
135
|
+
PATH
|
|
136
|
+
remote: .
|
|
137
|
+
specs:
|
|
138
|
+
demo (1.2.3)
|
|
139
|
+
|
|
140
|
+
GEM
|
|
141
|
+
remote: https://rubygems.org/
|
|
142
|
+
|
|
143
|
+
PLATFORMS
|
|
144
|
+
ruby
|
|
145
|
+
|
|
146
|
+
DEPENDENCIES
|
|
147
|
+
demo!
|
|
148
|
+
|
|
149
|
+
BUNDLED WITH
|
|
150
|
+
2.7.2
|
|
151
|
+
LOCK
|
|
152
|
+
|
|
153
|
+
_status, out, _err = invoke(["bump", "minor"], dir)
|
|
154
|
+
|
|
155
|
+
out.should.match(/Relocking Gemfile\.lock/)
|
|
156
|
+
File.read(File.join(dir, "Gemfile.lock")).should.match(/demo \(1\.3\.0\)/)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "says nothing about a lockfile that does not record this gem" do
|
|
161
|
+
with_gem do |dir|
|
|
162
|
+
_status, out, _err = invoke(["bump", "minor"], dir)
|
|
163
|
+
out.should.not.match(/Relocking/)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
98
167
|
it "mentions deprecations outstanding but not yet due" do
|
|
99
168
|
with_gem do |dir|
|
|
100
169
|
_status, out, _err = invoke(["bump", "minor"], dir, deprecations: [["Old", "New", "9.0"]])
|
|
@@ -105,6 +105,21 @@ module GemKit
|
|
|
105
105
|
multi_gem? ? "CHANGELOG-#{name}.md" : "CHANGELOG.md"
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
def lockfile_path
|
|
109
|
+
File.join(root, "Gemfile.lock")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# A Gemfile that says `gemspec` or `path: "."` puts this gem in its own
|
|
113
|
+
# bundle, and the lockfile then records this gem's version. Bumping
|
|
114
|
+
# without relocking leaves the two disagreeing — which bundler reports as
|
|
115
|
+
# "the gemspecs for path gems changed", and refuses outright under
|
|
116
|
+
# frozen mode, as bundlerEnv sets.
|
|
117
|
+
def self_locked?
|
|
118
|
+
return false unless File.exist?(lockfile_path)
|
|
119
|
+
|
|
120
|
+
File.read(lockfile_path).match?(/^\s{4}#{Regexp.escape(name)} \(\d/)
|
|
121
|
+
end
|
|
122
|
+
|
|
108
123
|
# `v1.2.3` says which version but not which gem, which is fine until a
|
|
109
124
|
# repository holds two of them at the same version.
|
|
110
125
|
def tag_prefix
|
|
@@ -252,6 +267,38 @@ describe "gem_kit/release/project" do
|
|
|
252
267
|
end
|
|
253
268
|
end
|
|
254
269
|
|
|
270
|
+
# A gem whose own Gemfile pulls it in has its version written in the lockfile
|
|
271
|
+
# as well as the version file, and both have to move together.
|
|
272
|
+
it "knows whether the lockfile records this gem's own version" do
|
|
273
|
+
with_project.call do |dir|
|
|
274
|
+
GemKit::Release::Project.detect(dir).self_locked?.should.be.false
|
|
275
|
+
|
|
276
|
+
File.write(File.join(dir, "Gemfile.lock"), <<~LOCK)
|
|
277
|
+
PATH
|
|
278
|
+
remote: .
|
|
279
|
+
specs:
|
|
280
|
+
demo (1.2.3)
|
|
281
|
+
|
|
282
|
+
GEM
|
|
283
|
+
remote: https://rubygems.org/
|
|
284
|
+
LOCK
|
|
285
|
+
GemKit::Release::Project.detect(dir).self_locked?.should.be.true
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
it "does not mistake another gem's line in the lockfile for its own" do
|
|
290
|
+
with_project.call do |dir|
|
|
291
|
+
File.write(File.join(dir, "Gemfile.lock"), <<~LOCK)
|
|
292
|
+
GEM
|
|
293
|
+
remote: https://rubygems.org/
|
|
294
|
+
specs:
|
|
295
|
+
other-demo (1.0.0)
|
|
296
|
+
demo-helper (2.0.0)
|
|
297
|
+
LOCK
|
|
298
|
+
GemKit::Release::Project.detect(dir).self_locked?.should.be.false
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
255
302
|
it "finds an ERB version template when the project generates its version file" do
|
|
256
303
|
with_project.call do |dir|
|
|
257
304
|
GemKit::Release::Project.detect(dir).version_template.should.be.nil
|