Class: GFSM::Tools::VersionBumper

Inherits:
Object
  • Object
show all
Defined in:
lib/tools/version_bumper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ VersionBumper

Returns a new instance of VersionBumper.



123
124
125
# File 'lib/tools/version_bumper.rb', line 123

def initialize(settings)
  @settings = settings
end

Instance Attribute Details

#subdivisionsObject (readonly)

Returns the value of attribute subdivisions.



121
122
123
# File 'lib/tools/version_bumper.rb', line 121

def subdivisions
  @subdivisions
end

#versionObject (readonly)

Returns the value of attribute version.



121
122
123
# File 'lib/tools/version_bumper.rb', line 121

def version
  @version
end

Instance Method Details

#executeObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/tools/version_bumper.rb', line 127

def execute
  changelog_commits = GFSM::Tools::GitUtilities.extract_commits_with_changelog_trailer(@settings.repository, @settings.from, @settings.to)

  @version = GFSM::Tools::CurrentVersionLoader.load_current_version(@settings.repository, @settings.initial_version)
  @subdivisions = GFSM::Tools::CommitsSubdivider.subdivide_commits(@settings.configuration, changelog_commits)

  if !@subdivisions || @subdivisions.empty?
    if @settings.force
      @version.bump!(@settings.force_version == "major", @settings.force_version == "minor", @settings.force_version == "patch", @settings.prerelease, @settings.prerelease_name)
    end
  else
    highest_bump = GFSM::Data::ChangeType.find_highest_bump(@subdivisions.keys)
    @version.bump!(highest_bump == :major, highest_bump == :minor, highest_bump == :patch, @settings.prerelease, @settings.prerelease_name)
  end

  return @version
end