Skip to content

Commit 01bfe30

Browse files
committed
[Bug #19340] Fix bundle gems with test revision
Build temporary gem package from cloned repository if test revision is set.
1 parent ba45be3 commit 01bfe30

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

common.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,10 +1404,10 @@ extract-gems$(gnumake:yes=-sequential): PHONY
14041404
-e 'gem, ver, _, rev = *$$F' \
14051405
-e 'next if !ver or /^#/=~gem' \
14061406
-e 'g = "#{gem}-#{ver}"' \
1407-
-e 'if File.directory?("#{d}/#{g}")' \
1408-
-e 'elsif rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \
1409-
-e 'BundledGem.copy(gs, ".bundle")' \
1410-
-e 'else' \
1407+
-e 'unless File.directory?("#{d}/#{g}")' \
1408+
-e 'if rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \
1409+
-e 'BundledGem.build(gs, ver, "gems")' \
1410+
-e 'end' \
14111411
-e 'BundledGem.unpack("gems/#{g}.gem", ".bundle")' \
14121412
-e 'end' \
14131413
gems/bundled_gems

defs/gmake.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,27 +326,27 @@ $(srcdir)/.bundle/gems/%: $(srcdir)/gems/%.gem | .bundle/gems
326326
-Itool/lib -rbundled_gem \
327327
-e 'BundledGem.unpack("gems/$(@F).gem", ".bundle")'
328328

329-
define copy-gem
329+
define build-gem
330330
$(srcdir)/gems/src/$(1): | $(srcdir)/gems/src
331331
$(ECHO) Cloning $(4)
332332
$(Q) $(GIT) clone $(4) $$(@)
333333

334-
$(srcdir)/.bundle/gems/$(1)-$(2): | $(srcdir)/gems/src/$(1) .bundle/gems
335-
$(ECHO) Copying $(1)@$(3) to $$(@F)
334+
$(srcdir)/gems/$(1)-$(2).gem: | $(srcdir)/gems/src/$(1)
335+
$(ECHO) Building $(1)@$(3) to $$(@F)
336336
$(Q) $(CHDIR) "$(srcdir)/gems/src/$(1)" && \
337337
$(GIT) fetch origin $(3) && \
338338
$(GIT) checkout --detach $(3) && \
339339
:
340340
$(Q) $(BASERUBY) -C "$(srcdir)" \
341341
-Itool/lib -rbundled_gem \
342-
-e 'BundledGem.copy("gems/src/$(1)/$(1).gemspec", ".bundle")'
342+
-e 'BundledGem.build("gems/src/$(1)/$(1).gemspec", "$(2)", "gems")'
343343

344344
endef
345-
define copy-gem-0
346-
$(eval $(call copy-gem,$(1),$(2),$(3),$(4)))
345+
define build-gem-0
346+
$(eval $(call build-gem,$(1),$(2),$(3),$(4)))
347347
endef
348348

349-
$(call foreach-bundled-gems-rev,copy-gem-0)
349+
$(call foreach-bundled-gems-rev,build-gem-0)
350350

351351
$(srcdir)/gems/src:
352352
$(MAKEDIRS) $@

tool/lib/bundled_gem.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ def unpack(file, *rest)
1414
puts "Unpacked #{file}"
1515
end
1616

17+
def build(gemspec, version, outdir = ".", validation: true)
18+
outdir = File.expand_path(outdir)
19+
gemdir, gemfile = File.split(gemspec)
20+
Dir.chdir(gemdir) do
21+
spec = Gem::Specification.load(gemfile)
22+
abort "Failed to load #{gemspec}" unless spec
23+
abort "Unexpected version #{spec.version}" unless spec.version == Gem::Version.new(version)
24+
Gem::Package.build(spec, validation == false, validation, File.join(outdir, spec.file_name))
25+
end
26+
end
27+
1728
def copy(path, *rest)
1829
path, n = File.split(path)
1930
spec = Dir.chdir(path) {Gem::Specification.load(n)} or raise "Cannot load #{path}"

0 commit comments

Comments
 (0)