Class: Changelog::Helpers::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/changelog/helpers/git.rb

Class Method Summary collapse

Class Method Details

.comment(sha) ⇒ Object



4
5
6
# File 'lib/changelog/helpers/git.rb', line 4

def self.comment(sha)
  `git show #{sha} -s --format=%B`.strip
end

.compare_url(sha1, sha2) ⇒ Object



28
29
30
# File 'lib/changelog/helpers/git.rb', line 28

def self.compare_url(sha1, sha2)
  (base_url = github_url) && "#{base_url}/compare/#{sha1}...#{sha2}"
end

.github_urlObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/changelog/helpers/git.rb', line 16

def self.github_url
  if origin = origin_url
    if origin =~ /github\.com/
      if origin =~ /^https/
        origin
      else
        "https://github.com/#{origin.gsub(/git@.+:/, '').gsub(/\.git/, '')}"
      end
    end
  end
end

.origin_urlObject



8
9
10
# File 'lib/changelog/helpers/git.rb', line 8

def self.origin_url
  `git config --get remote.origin.url`.strip.presence
end

.tag(version) ⇒ Object



12
13
14
# File 'lib/changelog/helpers/git.rb', line 12

def self.tag(version)
  `git tag | grep "#{version}$"`.split("\n").first
end