8000 [Bug #19340] Fix bundle gems with test revision by nobu · Pull Request #7146 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

[Bug #19340] Fix bundle gems with test revision #7146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Bug #19340] Fix bundle gems with test revision
Build temporary gem package from cloned repository if test revision is
set.
  • Loading branch information
nobu committed Jan 20, 2023
commit e10d01f6376005e236ebaa6b2ac9d97bc5e25575
8 changes: 4 additions & 4 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,10 @@ extract-gems$(gnumake:yes=-sequential): PHONY
-e 'gem, ver, _, rev = *$$F' \
-e 'next if !ver or /^#/=~gem' \
-e 'g = "#{gem}-#{ver}"' \
-e 'if File.directory?("#{d}/#{g}")' \
-e 'elsif rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \
-e 'BundledGem.copy(gs, ".bundle")' \
-e 'else' \
-e 'unless File.directory?("#{d}/#{g}")' \
-e 'if rev and File.exist?(gs = "gems/src/#{gem}/#{gem}.gemspec")' \
-e 'BundledGem.build(gs, ver, "gems")' \
-e 'end' \
-e 'BundledGem.unpack("gems/#{g}.gem", ".bundle")' \
-e 'end' \
gems/bundled_gems
Expand Down
15 changes: 8 additions & 7 deletions defs/gmake.mk
B8C5
Original file line number Diff line number Diff line change
Expand Up @@ -326,27 +326,28 @@ $(srcdir)/.bundle/gems/%: $(srcdir)/gems/%.gem | .bundle/gems
-Itool/lib -rbundled_gem \
-e 'BundledGem.unpack("gems/$(@F).gem", ".bundle")'

define copy-gem
define build-gem
$(srcdir)/gems/src/$(1): | $(srcdir)/gems/src
$(ECHO) Cloning $(4)
$(Q) $(GIT) clone $(4) $$(@)

$(srcdir)/.bundle/gems/$(1)-$(2): | $(srcdir)/gems/src/$(1) .bundle/gems
$(ECHO) Copying $(1)@$(3) to $$(@F)
.PHONY: $(srcdir)/gems/$(1)-$(2).gem
$(srcdir)/gems/$(1)-$(2).gem: | $(srcdir)/gems/src/$(1)
$(ECHO) Building $(1)@$(3) to $$(@F)
$(Q) $(CHDIR) "$(srcdir)/gems/src/$(1)" && \
$(GIT) fetch origin $(3) && \
$(GIT) checkout --detach $(3) && \
:
$(Q) $(BASERUBY) -C "$(srcdir)" \
-Itool/lib -rbundled_gem \
-e 'BundledGem.copy("gems/src/$(1)/$(1).gemspec", ".bundle")'
-e 'BundledGem.build("gems/src/$(1)/$(1).gemspec", "$(2)", "gems")'

endef
define copy-gem-0
$(eval $(call copy-gem,$(1),$(2),$(3),$(4)))
define build-gem-0
$(eval $(call build-gem,$(1),$(2),$(3),$(4)))
endef

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

$(srcdir)/gems/src:
$(MAKEDIRS) $@
Expand Down
13 changes: 13 additions & 0 deletions tool/lib/bundled_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ def unpack(file, *rest)
puts "Unpacked #{file}"
end

def build(gemspec, version, outdir = ".", validation: true)
outdir = File.expand_path(outdir)
gemdir, gemfile = File.split(gemspec)
Dir.chdir(gemdir) do
spec = Gem::Specification.load(gemfile)
abort "Failed to load #{gemspec}" unless spec
abort "Unexpected version #{spec.version}" unless spec.version == Gem::Version.new(version)
output = File.join(outdir, spec.file_name)
FileUtils.rm_rf(output)
Gem::Package.build(spec, validation == false, validation, output)
end
end

def copy(path, *rest)
path, n = File.split(path)
spec = Dir.chdir(path) {Gem::Specification.load(n)} or raise "Cannot load #{path}"
Expand Down
0