Class: Lolcommits::MercurialInfo

Inherits:
VCSInfo
  • Object
show all
Includes:
Methadone::CLILogging
Defined in:
lib/lolcommits/backends/mercurial_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VCSInfo

base_message

Constructor Details

#initializeMercurialInfo

Returns a new instance of MercurialInfo.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lolcommits/backends/mercurial_info.rb', line 16

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 'MercurialInfo: parsed the following values from commit:'
  debug "MercurialInfo: \t#{message}"
  debug "MercurialInfo: \t#{sha}"
  debug "MercurialInfo: \t#{repo_internal_path}"
  debug "MercurialInfo: \t#{repo}"
  debug "MercurialInfo: \t#{branch}"
  debug "MercurialInfo: \t#{author_name}" if author_name
  debug "MercurialInfo: \t#{author_email}" if author_email
end

Instance Attribute Details

#author_emailObject

Returns the value of attribute author_email.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def author_email
  @author_email
end

#author_nameObject

Returns the value of attribute author_name.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def author_name
  @author_name
end

#branchObject

Returns the value of attribute branch.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def branch
  @branch
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def message
  @message
end

#repoObject

Returns the value of attribute repo.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def repo
  @repo
end

#repo_internal_pathObject

Returns the value of attribute repo_internal_path.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def repo_internal_path
  @repo_internal_path
end

#shaObject

Returns the value of attribute sha.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def sha
  @sha
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/lolcommits/backends/mercurial_info.rb', line 5

def url
  @url
end

Class Method Details

.local_name(path = '.') ⇒ Object



12
13
14
# File 'lib/lolcommits/backends/mercurial_info.rb', line 12

def self.local_name(path = '.')
  File.basename(File.dirname(Mercurial::Repository.open(path).dothg_path))
end

.repo_root?(path = '.') ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/lolcommits/backends/mercurial_info.rb', line 8

def self.repo_root?(path = '.')
  File.directory?(File.join(path, '.hg'))
end