repo.or.cz
/
rubygit.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
added files from the gitrb project, which seems abandoned, but which is great code
[rubygit.git]
/
lib
/
git
/
raw
/
internal
/
object.rb
blob
b81df2b72c5feb508e2713c72c2a4043009bc0ac
1
require 'digest/sha1'
2
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
9
10
OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze
11
12
class RawObject
13
attr_accessor :type, :content
14
def initialize(type, content)
15
@type = type
16
@content = content
17
end
18
19
def sha1
20
Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
21
end
22
end
23
end end