module PrSummary::Git

Public Class Methods

call(cmd) click to toggle source
# File lib/pr_summary/git.rb, line 23
def call(cmd)
  temp_file do |path|
    git_cmd = "git #{cmd} > #{path}"
    puts git_cmd if ENV["DEBUG"]
    system(git_cmd)
  end
end
org() click to toggle source
# File lib/pr_summary/git.rb, line 11
def org
  `git remote get-url origin`.split(":").last.split("/").first.chomp
end
repo() click to toggle source
# File lib/pr_summary/git.rb, line 7
def repo
  `basename \`git rev-parse --show-toplevel\``.chomp
end
temp_file(name=('a'..'z').to_a.sample(5), &block) click to toggle source
# File lib/pr_summary/git.rb, line 15
def temp_file(name=('a'..'z').to_a.sample(5), &block)
  tmp_file = Tempfile.new(name)
  block.call(tmp_file.path)
  tmp_file.tap(&:rewind).read.chomp.tap do
    tmp_file.close
  end.to_s
end