summaryrefslogtreecommitdiffstats
path: root/lib/git/raw/internal/object.rb
blob: b81df2b72c5feb508e2713c72c2a4043009bc0ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'digest/sha1'

module Git module Raw module Internal
  OBJ_NONE = 0
  OBJ_COMMIT = 1
  OBJ_TREE = 2
  OBJ_BLOB = 3
  OBJ_TAG = 4

  OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze

  class RawObject
    attr_accessor :type, :content
    def initialize(type, content)
      @type = type
      @content = content
    end

    def sha1
      Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
    end
  end
end end