Class: SemVerComponents::Outputs::SemanticReleaseAnalyze

Inherits:
SemVerComponents::Output show all
Defined in:
lib/sem_ver_components/outputs/semantic_release_analyze.rb

Instance Method Summary collapse

Methods inherited from SemVerComponents::Output

#initialize

Constructor Details

This class inherits a constructor from SemVerComponents::Output

Instance Method Details

#process(commits_info) ⇒ Object

Process commits info

Parameters
  • commits_info (Array< Hash<Symbol, Object> >): List of commits info:

    • components_bump_levels (Hash<String or nil, Integer>): Set of bump levels (0: patch, 1: minor, 2: major) per component name (nil for global)

    • commit (Git::Object::Commit): Corresponding git commit



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sem_ver_components/outputs/semantic_release_analyze.rb', line 13

def process(commits_info)
  bump_level = commits_info.map { |commit_info| commit_info[:components_bump_levels].values }.flatten(1).max
  puts(
    case bump_level
    when nil
      # No commit. Return nothing to bump.
      ''
    when 0
      'patch'
    when 1
      'minor'
    when 2
      'major'
    else
      raise "Invalid bump level: #{bump_level}"
    end
  )
end