Sha256: 394426454fc9b06480fb39dacad004194e029bc6a2369188f4995dd460153dd4

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true

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

module GFSM
  module Tools
    class CurrentVersionLoader
      def self.load_current_version(repo_path = ".")
        repo = Git.open(repo_path)
        begin
          last_tag_name = repo.describe(nil, { abbrev: 0 })
        rescue
          last_tag_name = nil
        end

        return GFSM::Data::Version.new("0.0.0") unless last_tag_name

        if last_tag_name.downcase.start_with?("v") 
          last_tag_name.slice!(0)
        end

        GFSM::Data::Version.new(last_tag_name)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gfsm-0.1.2 lib/tools/current_version_loader.rb