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