From 33c5c36f5a386d6a42e71780b37878e6a16fca3d Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Sat, 30 Aug 2014 12:30:43 +0300 Subject: [PATCH] Add resque clause to patched? method. Fix #29. --- app/models/fedora_rpm.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/models/fedora_rpm.rb b/app/models/fedora_rpm.rb index 2c262dd..483c32a 100644 --- a/app/models/fedora_rpm.rb +++ b/app/models/fedora_rpm.rb @@ -110,10 +110,14 @@ def retrieve_version(fedora_version) rpm = Pkgwat.get_releases(name).select do |r| r['release'] == fedora_version end - if !!(rpm.first['stable_version'].match(/href/)) - rpm.first['stable_version'].scan(/>.*-/)[0].gsub(/[>-]/, '') + version = rpm.first['stable_version'] + + if !!(version.match(/href/)) + version.scan(/>.*-/)[0].gsub(/[>-]/, '') + elsif version.include?('-') + version.split('-').first else - rpm.first['stable_version'].split('-').first + version end end @@ -174,9 +178,13 @@ def any_patched? # - "fN" where N the Fedora version number, eg: 22,21,20,19,etc. # If no parameter is passed, it defaults to master. def patched?(version_git = 'master') - spec_url = "#{base_uri}#{name}.git/plain/#{name}.spec?h=#{version_git}" - rpm_spec = open(spec_url).read - rpm_spec.scan(/\nPatch0:\s*.*\n/).size != 0 + + url = "#{spec_uri}?h=#{version_git}" + begin + open(url).read.scan(/\nPatch0:\s*.*\n/).size != 0 + rescue OpenURI::HTTPError + false + end end # Get the alias mail for the package.