Sha256: 2728ea15a8d9206465773447edce16f50747a7c38d880e691e31d67c0a5e963b

Contents?: true

Size: 621 Bytes

Versions: 2

Compression:

Stored size: 621 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, { :tags => true, :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

2 entries across 2 versions & 1 rubygems

Version Path
gfsm-0.3.0 lib/tools/current_version_loader.rb
gfsm-0.2.0 lib/tools/current_version_loader.rb