Sha256: aaf349c60f2d919cc0fef1a22f8cf4d7eb1d31ce712c84f12ad75019c651bad9

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

require 'rugged'

require 'method_log/commit'

module MethodLog
  class Repository
    attr_reader :commits

    def initialize(path: nil)
      @repository = Rugged::Repository.new(path)
      @commits = []
      if @repository.ref('refs/heads/master')
        @repository.walk(@repository.last_commit) do |commit|
          @commits << build_commit(sha: commit.oid)
        end
      end
    end

    def build_commit(sha: nil)
      Commit.new(repository: @repository, sha: sha)
    end

    def add(commit)
      commit.apply
      @commits << commit
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
method_log-0.0.3 lib/method_log/repository.rb
method_log-0.0.2 lib/method_log/repository.rb