class Lolcommits::MercurialInfo
Public Class Methods
local_name(path = '.')
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 9 def self.local_name(path = '.') File.basename(File.dirname(Mercurial::Repository.open(path).dothg_path)) end
new()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 13 def initialize # mercurial sets HG_RESULT for post- hooks if ENV.key?('HG_RESULT') && ENV['HG_RESULT'] != '0' debug 'Aborting lolcommits hook from failed operation' exit 1 end Mercurial.configure do |conf| conf.hg_binary_path = 'hg' end debug 'parsed the following values from commit:' debug "\t#{message}" debug "\t#{sha}" debug "\t#{repo_internal_path}" debug "\t#{repo}" debug "\t#{branch}" debug "\t#{commit_date}" debug "\t#{author_name}" if author_name debug "\t#{author_email}" if author_email end
repo_root?(path = '.')
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 5 def self.repo_root?(path = '.') File.directory?(File.join(path, '.hg')) end
Public Instance Methods
branch()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 34 def branch @branch ||= last_commit.branch_name end
commit_date()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 69 def commit_date @commit_date ||= last_commit.date.utc end
message()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 38 def message @message ||= begin message = last_commit.message || '' message.split("\n").first end end
repo()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 57 def repo @repo ||= File.basename(File.dirname(repo_internal_path)) end
repo_internal_path()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 49 def repo_internal_path @repo_internal_path ||= repository.dothg_path end
sha()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 45 def sha @sha ||= last_commit.id[0..10] end
url()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 53 def url @url ||= repository.path end
Private Instance Methods
debug(message)
click to toggle source
Calls superclass method
# File lib/lolcommits/backends/mercurial_info.rb, line 75 def debug(message) super("#{self.class}: #{message}") end
last_commit()
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 83 def last_commit @last_commit ||= repository.commits.parent end
repository(path = '.')
click to toggle source
# File lib/lolcommits/backends/mercurial_info.rb, line 79 def repository(path = '.') @repository ||= Mercurial::Repository.open(path) end