module Gemspec::Git

Public Instance Methods

cdroot(&blk) click to toggle source

Go to the repo's root – block must be given

# File lib/gemspec/git.rb, line 45
def cdroot(&blk)
  return unless blk
  cdroot! &blk
end
cdroot!(&blk) click to toggle source

Go to the repo's root (and back if a block is given)

# File lib/gemspec/git.rb, line 34
def cdroot!(&blk)
  cdup = '.' if (cdup=`git rev-parse --show-cdup`.chomp) == ""
  if blk
    Dir.chdir cdup, &blk
  else
    Dir.chdir cdup
  end
end
clean?() click to toggle source
# File lib/gemspec/git.rb, line 50
def clean?
  `git status --porcelain`.chomp == ""
end
config() click to toggle source
# File lib/gemspec/git.rb, line 14
        def config
  cmd = %w[git config --list]
  config = SuperHash.new
  IO.popen(cmd).each do |line|
    line.chomp!
    path, _, value = line.partition("=")
    path = path.split(".").map(&:to_sym)
    path, assign = path[0...-1], path[-1]
    (path.reduce(config) {|acc,key| acc[key] })[assign] = value
  end
  config
end
ls_authors() click to toggle source
# File lib/gemspec/git.rb, line 27
        def ls_authors
  authors = `git log > /dev/null 2>&1 && git shortlog -sn`.split("\n").map {|a| a.sub(/^[\d\s]*/, '') }
  authors = (authors.empty? && [ `git config user.name` ]) || authors
end
ls_files() click to toggle source
# File lib/gemspec/git.rb, line 10
        def ls_files
  `git ls-files -z`.split("\x0")
end