Re: PATCH for gem2deb: gem2tgz will pick the newest gemfile instead of the first one
On Tue, Feb 28, 2012 at 8:42 AM, Matijs van Zuijlen <matijs@matijs.net> wrote:
> On 02/28/2012 03:18 PM, Antonio Terceiro wrote:
>> before = Dir::glob("#{gemfile}-*.gem")
>> run("gem fetch #{gemfile}")
>> after = Dir::glob("#{gemfile}-*.gem")
>> gemfile = (after - before).first
> Then, running `gem2tgz <basename>` twice would result in a failure.
I decided to pull out part of the code. Here is my take on the fix:
# Not the best solution in the world (actually far from it probably)
# but it's much less buggy then the current implementation (IMNSHO)
#
# 1.) Fixes a problem where it would think dir.gem is a real gem
# though not fully, this should really also check the filetype.
# 2.) Fixes a problem where gem2tgz automatically assumes that there
# can't be other gems with a close to the same name.
# 3.) Uses . instead of :: (obvious >.<)
RUBYGEM_VERSION_REGEX = /\A\s*([0-9]+(\.[0-9a-zA-Z]+)*)*\s*\z/
gemfile = ARGV[0]
if !File.file?(gemfile) && gemfile !~ /\.gem\Z/
puts "#{gemfile} doesn't seem to exist. Attempting to download it
from RubyGems.org"
run("gem fetch #{gemfile}")
gemfile = Dir.glob("#{gemfile}-*.gem").delete_if do |gemname|
gemname = gemname.gsub(/\.gem\Z/, '').split('-')
gemversion = gemname.pop
gemversion !~ RUBYGEM_VERSION_REGEX || gemname.join('-') != gemfile
end.sort.last
end
I didn't test it beyond the glob against a bunch of pry-0.9.8.*.gem
and pry-vterm_alias-0.*.gem. I am sticking to my guns that gem2gz and
gem2deb as a whole needs quite a bit of work to be up to par for
production (I know it's already production but meh I hope you get what
I mean)
Reply to: