class MethodLog::Repository
Public Class Methods
new(path)
click to toggle source
# File lib/method_log/repository.rb, line 7 def initialize(path) @repository = Rugged::Repository.new(path) @commits = [] end
Public Instance Methods
build_commit(sha = nil)
click to toggle source
# File lib/method_log/repository.rb, line 12 def build_commit(sha = nil) Commit.new(sha, @repository) end
commit(*source_files)
click to toggle source
# File lib/method_log/repository.rb, line 16 def commit(*source_files) options = source_files.pop if source_files.last.is_a?(Hash) options ||= {} options = { user: { email: 'test@example.com', name: 'test', time: Time.now }, message: 'commit-message' }.merge(options) build_commit.tap do |commit| source_files.each { |sf| commit.add(sf) } commit.apply(options) @commits << commit end end
commits(options = {})
click to toggle source
# File lib/method_log/repository.rb, line 27 def commits(options = {}) options[:sorting] ||= Rugged::SORT_TOPO Enumerator.new do |yielder| if @repository.ref('refs/heads/master') @repository.walk(@repository.last_commit, options[:sorting]).with_index do |commit, index| break if options[:max_count] && index >= options[:max_count] - 1 yielder << build_commit(commit.oid) end end end end