Sha256: dd236b8e92eb6ea38c98900b4b4bbb8efab7d8c48b67bfce65dc3f4c47c4ea3c

Contents?: true

Size: 1.03 KB

Versions: 8

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=self.tag)
      tag.strip.sub('v','').split(/[\.,-]/).select { |e| e.is_number?}.first(3).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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
overview-0.0.3.61 lib/appversion/git.rb
overview-0.0.3.56 lib/appversion/git.rb
overview-0.0.3.pre.debug.54 lib/appversion/git.rb
overview-0.0.3.pre.debug.51 lib/appversion/git.rb
overview-0.0.3.49 lib/appversion/git.rb
overview-0.0.3.47 lib/appversion/git.rb
overview-0.0.3.45 lib/appversion/git.rb
overview-0.0.2.43 lib/appversion/git.rb