Sha256: 164d95d0f99d6abb8263b522cd17970b70d81aa06e4262b7f21d2e70e884e24d

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'git'
require_relative '../data/version'

module GFSM
  module Tools
    class VersionBumper
      attr_reader :version, :subdivisions

      def compute_version!(force, prerelease, prerelease_name, repository_path, configuration_file_path)
        configuration = GFSM::Data::Configuration.new(configuration_file_path)
        changelog_commits = GFSM::Tools::CommitsExtractor.extract_commits_with_changelog_trailer(repository_path)

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

        if !subdivisions || subdivisions.empty?
          if force
            @version.bump!(false, false, true, prerelease, 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, prerelease, prerelease_name)
        end

        return @version
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gfsm-0.3.0 lib/tools/version_bumper.rb
gfsm-0.2.0 lib/tools/version_bumper.rb
gfsm-0.1.4 lib/tools/version_bumper.rb
gfsm-0.1.3 lib/tools/version_bumper.rb
gfsm-0.1.2 lib/tools/version_bumper.rb