Sha256: 6634138426932fd91f5abd616fdcc3f4a960cd271f5b5bdfab6733f32f53e068

Contents?: true

Size: 603 Bytes

Versions: 2

Compression:

Stored size: 603 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

2 entries across 2 versions & 1 rubygems

Version Path
gfsm-0.1.4 lib/tools/current_version_loader.rb
gfsm-0.1.3 lib/tools/current_version_loader.rb