Class: KStrano::GitHelper

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

Class Method Summary collapse

Class Method Details

.branch_name(commit = "HEAD") ⇒ Object



20
21
22
23
# File 'lib/helpers/git_helper.rb', line 20

def self.branch_name(commit = "HEAD")
  name = %x(git name-rev --name-only #{commit})
  name.strip
end

.commit_hash(commit = "HEAD") ⇒ Object



15
16
17
18
# File 'lib/helpers/git_helper.rb', line 15

def self.commit_hash(commit = "HEAD")
  hash = %x(git rev-parse #{commit})
  hash.strip
end

.fetchObject



6
7
8
# File 'lib/helpers/git_helper.rb', line 6

def self.fetch
  %x(git fetch)
end

.merge_base(commit1, commit2 = "HEAD") ⇒ Object



10
11
12
13
# File 'lib/helpers/git_helper.rb', line 10

def self.merge_base(commit1, commit2 = "HEAD")
  base = %x(git merge-base #{commit1} #{commit2})
  base.strip
end

.origin_refspecObject



25
26
27
28
# File 'lib/helpers/git_helper.rb', line 25

def self.origin_refspec
  refspec = %x(git config remote.origin.fetch)
  refspec.strip
end

.origin_urlObject



30
31
32
33
# File 'lib/helpers/git_helper.rb', line 30

def self.origin_url
  url = %x(git config remote.origin.url)
  url.strip
end