Class: GitHooks::GitAdapter
- Inherits:
-
Object
- Object
- GitHooks::GitAdapter
- Includes:
- Grit
- Defined in:
- lib/git_hooks/git_adapter.rb
Defined Under Namespace
Classes: Commits
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Class Method Summary collapse
Instance Method Summary collapse
- #find_commits_since_last_receive(prev_rev, current_rev, ref_name = 'master') ⇒ Object
-
#initialize ⇒ GitAdapter
constructor
A new instance of GitAdapter.
Constructor Details
#initialize ⇒ GitAdapter
Returns a new instance of GitAdapter.
47 48 49 |
# File 'lib/git_hooks/git_adapter.rb', line 47 def initialize @repo = Repo.new(GitAdapter.find_git_root) end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
45 46 47 |
# File 'lib/git_hooks/git_adapter.rb', line 45 def repo @repo end |
Class Method Details
.find_git_root ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/git_hooks/git_adapter.rb', line 57 def self.find_git_root current_dir = Dir.pwd.split('/') while current_dir.last !~ /\.git/ current_dir.pop break if current_dir.empty? end return current_dir.join('/') end |
Instance Method Details
#find_commits_since_last_receive(prev_rev, current_rev, ref_name = 'master') ⇒ Object
51 52 53 54 55 |
# File 'lib/git_hooks/git_adapter.rb', line 51 def find_commits_since_last_receive(prev_rev, current_rev, ref_name = 'master') commits = repo.commits_between(prev_rev, current_rev) return Commits.new(commits, ref_name, @repo) end |