Class: Lolcommits::GitInfo
- Inherits:
-
Object
- Object
- Lolcommits::GitInfo
- Defined in:
- lib/lolcommits/backends/git_info.rb
Constant Summary collapse
- GIT_URL_REGEX =
%r{.*[:]([\/\w\-]*).git}
Class Method Summary collapse
Instance Method Summary collapse
- #author_email ⇒ Object
- #author_name ⇒ Object
- #branch ⇒ Object
- #commit_date ⇒ Object
-
#initialize ⇒ GitInfo
constructor
A new instance of GitInfo.
- #message ⇒ Object
- #repo ⇒ Object
- #repo_internal_path ⇒ Object
- #sha ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ GitInfo
Returns a new instance of GitInfo.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lolcommits/backends/git_info.rb', line 13 def initialize debug 'GitInfo: parsed the following values from commit:' debug "GitInfo: \t#{message}" debug "GitInfo: \t#{sha}" debug "GitInfo: \t#{repo_internal_path}" debug "GitInfo: \t#{repo}" debug "GitInfo: \t#{branch}" debug "GitInfo: \t#{commit_date}" debug "GitInfo: \t#{author_name}" if debug "GitInfo: \t#{author_email}" if end |
Class Method Details
.local_name(path = '.') ⇒ Object
9 10 11 |
# File 'lib/lolcommits/backends/git_info.rb', line 9 def self.local_name(path = '.') File.basename(Git.open(path).dir.to_s) end |
.repo_root?(path = '.') ⇒ Boolean
5 6 7 |
# File 'lib/lolcommits/backends/git_info.rb', line 5 def self.repo_root?(path = '.') File.directory?(File.join(path, '.git')) end |
Instance Method Details
#author_email ⇒ Object
70 71 72 |
# File 'lib/lolcommits/backends/git_info.rb', line 70 def ||= last_commit..email if last_commit. end |
#author_name ⇒ Object
66 67 68 |
# File 'lib/lolcommits/backends/git_info.rb', line 66 def ||= last_commit..name if last_commit. end |
#branch ⇒ Object
25 26 27 |
# File 'lib/lolcommits/backends/git_info.rb', line 25 def branch @branch ||= repository.current_branch end |
#commit_date ⇒ Object
74 75 76 |
# File 'lib/lolcommits/backends/git_info.rb', line 74 def commit_date @commit_date ||= last_commit.date.utc end |
#message ⇒ Object
29 30 31 32 33 34 |
# File 'lib/lolcommits/backends/git_info.rb', line 29 def ||= begin = last_commit. || '' .split("\n").first end end |
#repo ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/lolcommits/backends/git_info.rb', line 52 def repo @repo ||= begin if repository.remote && repository.remote.url match = repository.remote.url.match(GIT_URL_REGEX) end if match match[1] elsif !repository.repo.path.empty? repository.repo.path.split(File::SEPARATOR)[-2] end end end |
#repo_internal_path ⇒ Object
40 41 42 |
# File 'lib/lolcommits/backends/git_info.rb', line 40 def repo_internal_path @repo_internal_path ||= repository.repo.path end |
#sha ⇒ Object
36 37 38 |
# File 'lib/lolcommits/backends/git_info.rb', line 36 def sha @sha ||= last_commit.sha[0..10] end |
#url ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/lolcommits/backends/git_info.rb', line 44 def url @url ||= begin if repository.remote && repository.remote.url remote_https_url(repository.remote.url) end end end |