Commit 44833e29 authored by Jonathan Riddell's avatar Jonathan Riddell 🛶

fix it up

parent e3936c27
......@@ -24,7 +24,7 @@ require 'optparse'
require_relative 'lib/appstream-metainfo-release-update'
@date = "today"
@release_to_show = 0
@releases_to_show = 0
parser = OptionParser.new do |opts|
opts.banner = <<-EOS
......@@ -32,15 +32,15 @@ Usage: appstream-metainfo-release-update 'org.foo.metainfo.xml'
EOS
opts.on("-v", "--version VERSION",
"version to add e.g. 1.0") do |vers|
@version << vers
@version = vers
end
opts.on("-d", "--datestring DATE_STRING",
"date to use 'today' 'next Thursday' '2018-01-01' etc") do |date_string|
@date << date_string
@date = date_string || "today"
end
opts.on("-r", "--releases_to_show RELEASES_TO_SHOW",
"how many releases to include in file (default infinite)") do |releases_to_show|
@releases_to_show = releases_to_show || 0
@releases_to_show = releases_to_show.to_i || 0
end
end
parser.parse!
......
......@@ -52,7 +52,7 @@ class MetaInfoUpdater
else
component.add_child("<releases><release version='#{@version}' date='#{date}'/></releases>")
end
if @releases_to_show > 0
if releases and @releases_to_show > 0
if releases.children.length > @releases_to_show
releases.children = releases.children[-@releases_to_show,@releases_to_show]
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment