class Git::Stats::Commit
Attributes
date[RW]
hash[RW]
repo[RW]
stats[RW]
title[RW]
Public Class Methods
new(repo, params)
click to toggle source
# File lib/git/stats/commit.rb, line 8 def initialize(repo, params) @repo = repo @hash = params[:commit_hash] @author_email = params[:author_email] @date = DateTime.parse(params[:commit_date], false).to_date @title = params[:commit_title] end
Public Instance Methods
commit_stat()
click to toggle source
# File lib/git/stats/commit.rb, line 20 def commit_stat result = { files: 0, insertions: 0, deletions: 0 } info = `cd #{@repo.folder} && git checkout #{repo.branch} > /dev/null 2>&1 && git show --stat #{@hash}`.split("\n").last.split(", ").map(&:strip) info.each do |e| if e =~ /^(\d+)\s(.+)$/ if $2.include?("file") result[:files] = $1.to_i elsif $2.include?("insertions") result[:insertions] = $1.to_i else result[:deletions] = $1.to_i end end end result end