Class: CodeRepository
- Inherits:
-
Object
- Object
- CodeRepository
- Defined in:
- lib/code_repository.rb
Instance Attribute Summary collapse
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
Instance Method Summary collapse
- #contributors(commit_list) ⇒ Object
- #get_head_ish ⇒ Object
-
#initialize(repository_path, from_commit, to_commit = nil) ⇒ CodeRepository
constructor
A new instance of CodeRepository.
- #lookup(oid) ⇒ Object
Constructor Details
#initialize(repository_path, from_commit, to_commit = nil) ⇒ CodeRepository
Returns a new instance of CodeRepository.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/code_repository.rb', line 5 def initialize(repository_path,from_commit,to_commit = nil) @commits = [] @repo = Rugged::Repository.new(repository_path) to_commit ||= get_head_ish walker = @repo.walk(to_commit) walker.each { |c| @commits << c break if c.oid == from_commit } end |
Instance Attribute Details
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
4 5 6 |
# File 'lib/code_repository.rb', line 4 def commits @commits end |
Instance Method Details
#contributors(commit_list) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/code_repository.rb', line 18 def contributors(commit_list) return [] if commit_list.empty? = [] commit_list.each do |oid| c = @repo.lookup(oid) next unless @commits.map(&:oid).include?(c.oid) = c. names = [:name] names = names.split("&") names.each{|n| n =n.strip << n unless .include?(n) } end end |
#get_head_ish ⇒ Object
36 37 38 |
# File 'lib/code_repository.rb', line 36 def get_head_ish @repo.head.target end |
#lookup(oid) ⇒ Object
40 41 42 |
# File 'lib/code_repository.rb', line 40 def lookup(oid) @repo.lookup(oid) end |