Class: Lolcommits::GitInfo
- Inherits:
-
Object
- Object
- Lolcommits::GitInfo
- Includes:
- Methadone::CLILogging
- Defined in:
- lib/lolcommits/git_info.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#repo_internal_path ⇒ Object
Returns the value of attribute repo_internal_path.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize ⇒ GitInfo
constructor
A new instance of GitInfo.
- #remote_https_url(url) ⇒ Object
Constructor Details
#initialize ⇒ GitInfo
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lolcommits/git_info.rb', line 11 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. = commit..split("\n").first self.sha = commit.sha[0..10] self.repo_internal_path = g.repo.path self.url = remote_https_url(g.remote.url) if g.remote.url regex = /.*[:]([\/\w\-]*).git/ match = g.remote.url.match regex if g.remote.url if match self.repo = match[1] elsif !g.repo.path.empty? self.repo = g.repo.path.split(File::SEPARATOR)[-2] end 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
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/lolcommits/git_info.rb', line 5 def end |
#repo ⇒ Object
Returns the value of attribute repo.
5 6 7 |
# File 'lib/lolcommits/git_info.rb', line 5 def repo @repo end |
#repo_internal_path ⇒ Object
Returns the value of attribute repo_internal_path.
5 6 7 |
# File 'lib/lolcommits/git_info.rb', line 5 def repo_internal_path @repo_internal_path end |
#sha ⇒ Object
Returns the value of attribute sha.
5 6 7 |
# File 'lib/lolcommits/git_info.rb', line 5 def sha @sha end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/lolcommits/git_info.rb', line 5 def url @url end |
Instance Method Details
#remote_https_url(url) ⇒ Object
7 8 9 |
# File 'lib/lolcommits/git_info.rb', line 7 def remote_https_url(url) url.gsub(':', '/').gsub(/^git@/, 'https://').gsub(/\.git$/, '') + '/commit/' end |