[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

PATCH for gem2deb: gem2tgz will pick the newest gemfile instead of the first one



Hi!

I noticed that gem2tgz would correctly fetch the latest version of a
gem, but if it happens that in the same directory, there are other
versions of the gem, it is very likely that it will use the wrong one to
build the tarball.

Here is a patch allowing gem2tgz to pick the lastest modified gemfile in
the directory, instead of the first one.

Another possibity would be to use Gem::Version to ensure we pick the
newest version, but it may be a bit overkill.

What do you think?

Cédric
From 72430753234f016467f13bbd0876c3401bf0fe31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Boutillier?= <cedric.boutillier@gmail.com>
Date: Mon, 27 Feb 2012 15:36:43 +0100
Subject: [PATCH] choose latest modified gem file instead of the first one

---
 bin/gem2tgz |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/bin/gem2tgz b/bin/gem2tgz
index b28d57d..8ed14eb 100755
--- a/bin/gem2tgz
+++ b/bin/gem2tgz
@@ -42,7 +42,8 @@ gemfile = ARGV[0]
 if not File::exists?(gemfile) and gemfile !~ /.gem$/
   puts "#{gemfile} doesn't seem to exist. Let's try to download it with 'gem fetch #{ARGV[0]}'"
   run("gem fetch #{gemfile}")
-  gemfile = Dir::glob("#{gemfile}-*.gem")[0]
+  # choose the latest modified gemfile
+  gemfile = Dir::glob("#{gemfile}-*.gem").max{ |a,b| File.mtime(a) <=> File.mtime(b) }
 end
 
 Gem2Deb::Gem2Tgz.convert!(gemfile, ARGV[1] || nil)
-- 
1.7.9.1

Attachment: signature.asc
Description: Digital signature


Reply to: