class RogerSneakpeek::Git

Get relevant git info

Public Instance Methods

branch() click to toggle source

Will return current branch

# File lib/roger_sneakpeek/git.rb, line 15
def branch
  get_scm_data if @_sha.nil?
  @_branch
end
sha() click to toggle source
# File lib/roger_sneakpeek/git.rb, line 9
def sha
  get_scm_data if @_sha.nil?
  @_sha
end
tag() click to toggle source
# File lib/roger_sneakpeek/git.rb, line 4
def tag
  get_scm_data if @_sha.nil?
  @_tag
end

Protected Instance Methods

get_scm_data(ref = @config[:ref]) click to toggle source
Calls superclass method
# File lib/roger_sneakpeek/git.rb, line 22
def get_scm_data(ref = @config[:ref])
  super(ref)

  @_tag = scm_tag(ref) || nil
  @_branch = scm_branch(ref) || nil
  @_sha = scm_sha(ref) || nil
end
scm_branch(ref) click to toggle source
# File lib/roger_sneakpeek/git.rb, line 38
def scm_branch(ref)
  return nil unless File.exist?(git_dir)

  branch = `git --git-dir=#{safe_git_dir} rev-parse --abbrev-ref #{ref} 2>&1`

  branch.strip if $CHILD_STATUS.to_i == 0
end
scm_sha(ref) click to toggle source
# File lib/roger_sneakpeek/git.rb, line 46
def scm_sha(ref)
  return nil unless File.exist?(git_dir)

  sha = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:"%H" -s 2>&1`

  sha.strip if $CHILD_STATUS.to_i == 0
end
scm_tag(ref) click to toggle source
# File lib/roger_sneakpeek/git.rb, line 30
def scm_tag(ref)
  return nil unless File.exist?(git_dir)

  tag = `git --git-dir=#{safe_git_dir} describe --tags --exact-match #{ref} 2>&1`

  tag.strip if $CHILD_STATUS.to_i == 0
end