Class: Overview::Git
- Inherits:
-
Object
- Object
- Overview::Git
- Defined in:
- lib/appversion/git.rb
Class Method Summary collapse
- .branch ⇒ Object
- .clean_tag(tag = self.tag) ⇒ Object
- .commit_count ⇒ Object
- .commit_count_since_tag(tag) ⇒ Object
- .installed? ⇒ Boolean
- .remote ⇒ Object
- .repo ⇒ Object
- .tag ⇒ Object
Class Method Details
.branch ⇒ Object
18 19 20 |
# File 'lib/appversion/git.rb', line 18 def self.branch CI.branch || `git rev-parse --abbrev-ref HEAD`.strip end |
.clean_tag(tag = self.tag) ⇒ Object
24 25 26 |
# File 'lib/appversion/git.rb', line 24 def self.clean_tag(tag=self.tag) tag.strip.sub('v','').split(/[\.,-]/).select { |e| e.is_number?}.first(3).join('.') end |
.commit_count ⇒ Object
27 28 29 |
# File 'lib/appversion/git.rb', line 27 def self.commit_count `git rev-list --count HEAD` end |
.commit_count_since_tag(tag) ⇒ Object
30 31 32 |
# File 'lib/appversion/git.rb', line 30 def self.commit_count_since_tag(tag) `git rev-list --count ${tag}.. 2>/dev/null` end |
.installed? ⇒ Boolean
33 34 35 |
# File 'lib/appversion/git.rb', line 33 def self.installed? system 'git --version >>/dev/null 2>&1' end |
.remote ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/appversion/git.rb', line 7 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 |
.tag ⇒ Object
21 22 23 |
# File 'lib/appversion/git.rb', line 21 def self.tag (`git describe --tags --match 'v*' --abbrev=0 2>/dev/null` || 'HEAD').strip end |