summaryrefslogtreecommitdiffstats
path: root/lib/git/raw/internal/object.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-20 12:07:46 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-20 12:07:46 -0800
commitd07a2c04c1599fe707831afdd29397cc36e02fa6 (patch)
tree8bde8310874c92c4c2a51998ff53166a8e8e2d94 /lib/git/raw/internal/object.rb
parent2cef1e66c395296620225c7ffd77b772c6ad4215 (diff)
downloadthird_party-ruby-git-d07a2c04c1599fe707831afdd29397cc36e02fa6.zip
third_party-ruby-git-d07a2c04c1599fe707831afdd29397cc36e02fa6.tar.gz
third_party-ruby-git-d07a2c04c1599fe707831afdd29397cc36e02fa6.tar.xz
added files from the gitrb project, which seems abandoned, but which is great code
Diffstat (limited to 'lib/git/raw/internal/object.rb')
-rw-r--r--lib/git/raw/internal/object.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/git/raw/internal/object.rb b/lib/git/raw/internal/object.rb
new file mode 100644
index 0000000..b81df2b
--- /dev/null
+++ b/lib/git/raw/internal/object.rb
@@ -0,0 +1,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