added files from the gitrb project, which seems abandoned, but which is great code
[rubygit.git] / lib / git / raw / internal / object.rb
blobb81df2b72c5feb508e2713c72c2a4043009bc0ac
1 require 'digest/sha1'
3 module Git module Raw module Internal
4   OBJ_NONE = 0
5   OBJ_COMMIT = 1
6   OBJ_TREE = 2
7   OBJ_BLOB = 3
8   OBJ_TAG = 4
10   OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze
12   class RawObject
13     attr_accessor :type, :content
14     def initialize(type, content)
15       @type = type
16       @content = content
17     end
19     def sha1
20       Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
21     end
22   end
23 end end