Class: Lolcommits::MercurialInfo
- Inherits:
-
Object
- Object
- Lolcommits::MercurialInfo
- Defined in:
- lib/lolcommits/backends/mercurial_info.rb
Class Method Summary collapse
Instance Method Summary collapse
- #author_email ⇒ Object
- #author_name ⇒ Object
- #branch ⇒ Object
- #commit_date ⇒ Object
-
#initialize ⇒ MercurialInfo
constructor
A new instance of MercurialInfo.
- #message ⇒ Object
- #repo ⇒ Object
- #repo_internal_path ⇒ Object
- #sha ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ MercurialInfo
Returns a new instance of MercurialInfo.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 11 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#{}" debug "\t#{sha}" debug "\t#{repo_internal_path}" debug "\t#{repo}" debug "\t#{branch}" debug "\t#{commit_date}" debug "\t#{}" if debug "\t#{}" if end |
Class Method Details
.local_name(path = ".") ⇒ Object
7 8 9 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 7 def self.local_name(path = ".") File.basename(File.dirname(Mercurial::Repository.open(path).dothg_path)) end |
.repo_root?(path = ".") ⇒ Boolean
3 4 5 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 3 def self.repo_root?(path = ".") File.directory?(File.join(path, ".hg")) end |
Instance Method Details
#author_email ⇒ Object
63 64 65 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 63 def @author_email ||= last_commit. end |
#author_name ⇒ Object
59 60 61 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 59 def @author_name ||= last_commit. end |
#branch ⇒ Object
32 33 34 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 32 def branch @branch ||= last_commit.branch_name end |
#commit_date ⇒ Object
67 68 69 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 67 def commit_date @commit_date ||= last_commit.date.utc end |
#message ⇒ Object
36 37 38 39 40 41 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 36 def @message ||= begin = last_commit. || "" .split("\n").first end end |
#repo ⇒ Object
55 56 57 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 55 def repo @repo ||= File.basename(File.dirname(repo_internal_path)) end |
#repo_internal_path ⇒ Object
47 48 49 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 47 def repo_internal_path @repo_internal_path ||= repository.dothg_path end |
#sha ⇒ Object
43 44 45 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 43 def sha @sha ||= last_commit.id[0..10] end |
#url ⇒ Object
51 52 53 |
# File 'lib/lolcommits/backends/mercurial_info.rb', line 51 def url @url ||= repository.path end |