class Referral::GitStore
Constants
- GROSS_BLAME_CACHE
Public Class Methods
blame(file)
click to toggle source
This format will look like: a50eb722 (<searls@gmail.com> 1561643971 -0400 2) class FirstThing or a50eb722 old/file/path.rb (<searls@gmail.com> 1561643971 -0400 2) class FirstThing
# File lib/referral/git_store.rb, line 35 def self.blame(file) GROSS_BLAME_CACHE[file] ||= begin out, _, status = Open3.capture3("git blame -e -t \"#{file}\"") status.success? ? out : "" end end
blame_line(file, line)
click to toggle source
# File lib/referral/git_store.rb, line 26 def self.blame_line(file, line) return unless (output = blame(file)) output.split("\n")[line - 1] end
sha(file, line)
click to toggle source
# File lib/referral/git_store.rb, line 8 def self.sha(file, line) return unless (output = blame_line(file, line)) return unless (match = output.match(/^(\w+)/)) match[1] end
time(file, line)
click to toggle source
# File lib/referral/git_store.rb, line 20 def self.time(file, line) return unless (output = blame_line(file, line)) return unless (match = output.match(/\(<.*?>\s+(\d+)\s+/)) Time.at(Integer(match[1])) end