[DRE-commits] [gem2deb] 02/04: PATCH for gem2deb: gem2tgz will pick the newest gemfile instead of the first one
Lucas Nussbaum
lucas at moszumanska.debian.org
Mon May 11 19:45:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
lucas pushed a commit to branch master
in repository gem2deb.
commit 25af6061193b1f84563a432633386b55fc0e8b6d
Author: Cédric Boutillier <cedric.boutillier at gmail.com>
Date: Mon Feb 27 23:52:19 2012 +0100
PATCH for gem2deb: gem2tgz will pick the newest gemfile instead of the first one
On Mon, Feb 27, 2012 at 05:18:34PM +0100, Matijs van Zuijlen wrote:
> I would definitely check the actual version of the gem rather than
> the mtime. There are all kinds of reasons an earlier version might
> have a later mtime accidentally.
Thanks for your feedback. Here is thus a second attempt, with the use of
Gem::Version.
I thought about writing a test for that, but this part is used
only when a gem is fetched. If we don't want to assume that we have a
network connection during the tests, I imagine that we need to create a
local gem repository, with two versions of the same simple gem, and
fetch from there.
Cédric
From c350c16494988b0bf9d42cca84ac580ff6a79d46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Boutillier?= <cedric.boutillier at gmail.com>
Date: Mon, 27 Feb 2012 15:36:43 +0100
Subject: [PATCH] choose most recent version of the gem file instead of the
first one
---
bin/gem2tgz | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/bin/gem2tgz b/bin/gem2tgz
index 2a18828..244b0c2 100755
--- a/bin/gem2tgz
+++ b/bin/gem2tgz
@@ -18,6 +18,8 @@
require 'gem2deb'
require 'gem2deb/gem2tgz'
require 'optparse'
+require 'rubygems'
+
optparse = OptionParser.new do |opts|
opts.banner = "Usage: gem2tgz [OPTIONS] GEMNAME|GEMFILE [TARBALL]"
@@ -45,7 +47,12 @@ 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]
+ versions = Dir::glob("#{gemfile}-*.gem").map do |a|
+ Gem::Version.new(a.sub(/#{gemfile}-(.+)\.gem/, '\1'))
+ end
+ # and pick the most recent one
+ last_version = versions.max
+ gemfile = "#{gemfile}-#{last_version}.gem"
end
Gem2Deb::Gem2Tgz.convert!(gemfile, ARGV[1] || nil)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git
More information about the Pkg-ruby-extras-commits
mailing list