Class: Lolcommits::GitInfo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitInfo

Returns a new instance of GitInfo.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lolcommits/git_info.rb', line 6

def initialize
  debug "GitInfo: attempting to read local repository"
  g    = Git.open('.')
  debug "GitInfo: reading commits logs"
  commit = g.log.first
  debug "GitInfo: most recent commit is '#{commit}'"

  self.message = commit.message.split("\n").first
  self.sha     = commit.sha[0..10]
  self.repo_internal_path = g.repo.path
  regex = /.*[:\/](\w*).git/
  match = g.remote.url.match regex if g.remote.url
  self.repo = match[1] if match
  
  debug "GitInfo: parsed the following values from commit:"
  debug "GitInfo: \t#{self.message}"
  debug "GitInfo: \t#{self.sha}"
  debug "GitInfo: \t#{self.repo_internal_path}" 
  debug "GitInfo: \t#{self.repo}"
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/lolcommits/git_info.rb', line 4

def message
  @message
end

#repoObject

Returns the value of attribute repo.



4
5
6
# File 'lib/lolcommits/git_info.rb', line 4

def repo
  @repo
end

#repo_internal_pathObject

Returns the value of attribute repo_internal_path.



4
5
6
# File 'lib/lolcommits/git_info.rb', line 4

def repo_internal_path
  @repo_internal_path
end

#shaObject

Returns the value of attribute sha.



4
5
6
# File 'lib/lolcommits/git_info.rb', line 4

def sha
  @sha
end