Skip to content

Commit

Permalink
Merge pre 0.7 and 0.7 together
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Mar 10, 2019
1 parent 56c8690 commit 45cf2ad
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions plugins/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,38 +75,37 @@ def canonical_url(input)
def group_components_by_release(input)
input.group_by { |v|
raise ArgumentError, "ha_release must be set in #{v.basename}" if v["ha_release"].nil?
v["ha_release"].to_s
release_str = v["ha_release"].to_s
if release_str == "pre 0.7"
release_str = "0.7"
end
release_str
}.map{ |v|
version = v[0]
if version == "pre 0.7"
version = "0.6"
end

begin
gem_ver = Gem::Version.new(version).to_s
rescue
raise ArgumentError, "Error when parsing ha_release #{version} in #{v.path}."
end

{ "label" => v[0], "new_components_count" => v[1].count, "sort_key" => gem_ver }
{ "label" => version, "new_components_count" => v[1].count, "sort_key" => gem_ver }
}.sort_by { |v| v["sort_key"] }.reverse.group_by { |v|
version = v["label"]

split_ver = version.split('.')
major = split_ver[0]
minor = split_ver[1]

if version == "pre 0.7"
"0.X"
elsif minor.length == 1
if minor.length == 1
"#{major}.X"
else
"#{major}.#{minor[0]}X"
end
}.map { |v|
sort_key = v[1][-1]["sort_key"]
if v[0] == "0.X"
sort_key = "0.01" # Ensure pre 0.7 is always sorted at bottom.
sort_key = "0.01" # Ensure 0.X is always sorted at bottom.
end

total_new_components = 0
Expand Down

0 comments on commit 45cf2ad

Please sign in to comment.