Sha256: cb7f81c1dc94be34c3bd1eafe6e05b81d16a7e9e27ec0985a6615d28d201199e

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require_relative 'string.rb'
require_relative 'ci.rb'

module Overview

  class Git
    def self.remote
      begin
        `git remote -v show`.lines.first.strip.match(/github\.com[\/|:](.+)\.git/)[1]
      rescue
        $stderr.puts 'Unable to retrieve slug from >> git remote -v show'
        exit 1
      end
    end
    def self.repo
      CI.repo || remote
    end
    def self.branch
      CI.branch || `git rev-parse --abbrev-ref HEAD`.strip
    end
    def self.tag
      (`git describe --tags --match 'v*' --abbrev=0 2>/dev/null` || 'HEAD').strip
    end
    def self.clean_tag
      tag.strip.sub('v','').split('.').select { |e| e.is_number?}.join('.')
    end
    def self.commit_count
      `git rev-list --count HEAD`
    end
    def self.commit_count_since_tag(tag)
      `git rev-list --count ${tag}.. 2>/dev/null`
    end
    def self.installed?
      system 'git --version >>/dev/null 2>&1'
    end
  end
  def clean_tag
    tag.strip.sub('v','').split('.').select { |e| e.is_number?}.join('.')
  end
end

#puts Overview::Git.clean_tag

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
overview-0.0.2.1.40 lib/appversion/git.rb