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
have the pure ruby bindings working to some degree
[rubygit.git]
/
lib
/
git
/
raw
/
internal
/
object.rb
blob
7f956851fe3da19b02e2903acb163344daabbad2
1
require 'digest/sha1'
2
3
module Git
4
module Raw
5
module Internal
6
OBJ_NONE = 0
7
OBJ_COMMIT = 1
8
OBJ_TREE = 2
9
OBJ_BLOB = 3
10
OBJ_TAG = 4
11
12
OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze
13
14
class RawObject
15
attr_accessor :type, :content
16
def initialize(type, content)
17
@type = type
18
@content = content
19
end
20
21
def sha1
22
Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
23
end
24
end
25
end
26
end
27
end