|
|
@ -62,16 +62,17 @@ def find_milestone(username, password, repository, title)
|
|
|
|
milestones = JSON.parse(response.body)
|
|
|
|
milestones = JSON.parse(response.body)
|
|
|
|
if title.end_with?(".x")
|
|
|
|
if title.end_with?(".x")
|
|
|
|
prefix = title.delete_suffix('.x')
|
|
|
|
prefix = title.delete_suffix('.x')
|
|
|
|
$log.debug "Finding latest milestone from candidates starting with #{prefix}"
|
|
|
|
$log.debug "Finding nearest milestone from candidates starting with #{prefix}"
|
|
|
|
titles = milestones.map { |milestone| milestone['title'] }
|
|
|
|
titles = milestones.map { |milestone| milestone['title'] }
|
|
|
|
titles = titles.select{ |title| title.start_with?(prefix) unless title.end_with?('.x')}
|
|
|
|
titles = titles.select{ |title| title.start_with?(prefix) unless title.end_with?('.x')}
|
|
|
|
titles.sort_by { |v| Gem::Version.new(v) }
|
|
|
|
titles = titles.sort_by { |v| Gem::Version.new(v) }
|
|
|
|
|
|
|
|
$log.debug "Considering candidates #{titles}"
|
|
|
|
if(titles.empty?)
|
|
|
|
if(titles.empty?)
|
|
|
|
puts "Cannot find latest for milestone #{title}"
|
|
|
|
puts "Cannot find nearest milestone for prefix #{title}"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
title = titles.last
|
|
|
|
title = titles.first
|
|
|
|
$log.debug "Found latest milestone #{title}"
|
|
|
|
$log.debug "Found nearest milestone #{title}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
milestones.each do |milestone|
|
|
|
|
milestones.each do |milestone|
|
|
|
|
$log.debug "Considering #{milestone['title']}"
|
|
|
|
$log.debug "Considering #{milestone['title']}"
|
|
|
|