Sha256: ce3cfaeb507de907303bd61f1fc4c013cfd719d9f8c23962ba67321801afe653
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'rugged' require 'method_log/commit' module MethodLog class Repository def initialize(path) @repository = Rugged::Repository.new(path) @commits = [] end def build_commit(sha = nil) Commit.new(sha, @repository) end 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
method_log-0.2.1 | lib/method_log/repository.rb |
method_log-0.2.0 | lib/method_log/repository.rb |