class Object
Public Instance Methods
infos()
click to toggle source
inspired by visionmedia//git-infos
# File lib/git_helpers/stats.rb, line 130 def infos with_dir do puts "## Remote URLs:" puts system("git --no-pager remote -v") puts puts "## Remote Branches:" puts system("git --no-pager branch -r") puts puts "## Local Branches:" puts system("git --no-pager branch") puts puts "## Most Recent Commit:" puts system("git --no-pager log --max-count=1 --pretty=short") puts end end
output_stats_lines()
click to toggle source
# File lib/git_helpers/stats.rb, line 73 def output_stats_lines stats=stats_lines_all total=stats.values.sum stats.sort_by{|k,v| -v}.each do |k,v| puts "- #{k}: #{v} (#{"%2.1f%%" % (100*v/total.to_f)})" end puts "Total lines: #{total}" end
summary(logopts=nil)
click to toggle source
inspired by visionmedia//git-summary
# File lib/git_helpers/stats.rb, line 155 def summary(logopts=nil) with_dir do project=Pathname.new(%x/git rev-parse --show-toplevel/).basename authors=stats_authors(logopts) commits=authors.map {|a,v| v[:commits]}.sum file_count=%x/git ls-files/.each_line.count active_days=%x/git log --date=short --pretty='format: %ad' #{logopts}/.each_line.uniq.count #This only give the rep age of the current branch; and is not #efficient since we generate the first log #A better way would be to get all the roots commits via # git rev-list --max-parents=0 HEAD #and then look at their ages repository_age=%x/git log --reverse --pretty=oneline --format="%ar" #{logopts}/.each_line.first.sub!('ago','') #total= %x/git rev-list #{logopts}/.each_line.count total=%x/git rev-list --count #{logopts.empty? ? "HEAD" : logopts.shelljoin}/.to_i puts " project : #{project}" puts " repo age : #{repository_age}" puts " active : #{active_days} days" puts " commits : #{commits}" puts " files : #{file_count}" puts " authors : #{authors.keys.join(", ")} (Total: #{total})" authors.each do |a,v| puts " - #{a}: #{v[:commits]} (#{"%2.1f" % (100*v[:commits]/commits.to_f)}%)" end end end