Sha256: b68814f2b3f11ff094b7e0406c34891adec9bee46db40c98bfa98853844f1f88

Contents?: true

Size: 568 Bytes

Versions: 1

Compression:

Stored size: 568 Bytes

Contents

require 'rugged'

require 'method_log/commit'

module MethodLog
  class Repository
    attr_reader :commits

    def initialize(path:)
      @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

1 entries across 1 versions & 1 rubygems

Version Path
method_log-0.0.1 lib/method_log/repository.rb