Class: SemVerComponents::Outputs::Info
- Inherits:
-
SemVerComponents::Output
- Object
- SemVerComponents::Output
- SemVerComponents::Outputs::Info
- Defined in:
- lib/sem_ver_components/outputs/info.rb
Overview
Output plugin displaying components' bump levels and next version info
Instance Method Summary collapse
-
#process(commits_info) ⇒ Object
Process commits info.
Methods inherited from SemVerComponents::Output
Constructor Details
This class inherits a constructor from SemVerComponents::Output
Instance Method Details
#process(commits_info) ⇒ Object
Process commits info
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sem_ver_components/outputs/info.rb', line 11 def process(commits_info) # Display bump levels per component bumps_per_component = commits_info.inject({}) do |components_bump_levels, commit_info| components_bump_levels.merge(commit_info[:components_bump_levels]) do |_component, bump_level1, bump_level2| [bump_level1, bump_level2].max end end bumps_per_component.each do |component, bump_level| puts "#{component.nil? ? 'Global' : component}: Bump #{ case bump_level when 0 'patch' when 1 'minor' when 2 'major' else raise "Invalid bump level: #{bump_level}" end } version" end # Compute new version global_bump_level = bumps_per_component.values.max if global_bump_level.nil? puts 'No next version' else puts "Next global version#{' (not on release branch)' unless @local_git.on_release_branch?}: #{ Semver.next_version_from(Semver.version_from_git_ref(@local_git.git_from), global_bump_level, pre_release: !@local_git.on_release_branch?) }" end end |