Sha256: 68be0873db52413f50029117bea3d3f1fb3f61ae27053fcdea803e332b63f78b

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 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::GitUtilities.extract_commits_with_changelog_trailer(
          GFSM::Tools::GitUtilities.load_repo(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

2 entries across 2 versions & 1 rubygems

Version Path
gfsm-0.3.2 lib/tools/version_bumper.rb
gfsm-0.3.1 lib/tools/version_bumper.rb