diff --git a/git/hooks/forward-merge b/git/hooks/forward-merge index c5f78c1b95..6877ff9d58 100755 --- a/git/hooks/forward-merge +++ b/git/hooks/forward-merge @@ -62,16 +62,17 @@ def find_milestone(username, password, repository, title) milestones = JSON.parse(response.body) if title.end_with?(".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 = 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?) - puts "Cannot find latest for milestone #{title}" + puts "Cannot find nearest milestone for prefix #{title}" exit 1 end - title = titles.last - $log.debug "Found latest milestone #{title}" + title = titles.first + $log.debug "Found nearest milestone #{title}" end milestones.each do |milestone| $log.debug "Considering #{milestone['title']}"