diff options
author | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-27 08:21:48 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.(none)> | 2007-11-27 08:21:48 -0800 |
commit | 779f21b307e7c119a56700fb14f88ba63a2cccc2 (patch) | |
tree | f3f03821dbe66f581ae2707e6e872395adc7afbe /lib/git/raw/internal/object.rb | |
parent | 55c3c134c5c19103ed52fbd615d5af351fa9bb34 (diff) | |
parent | 6a9db968e8563bc27b8f56f9d413159a2e14cf67 (diff) | |
download | third_party-ruby-git-779f21b307e7c119a56700fb14f88ba63a2cccc2.tar.gz third_party-ruby-git-779f21b307e7c119a56700fb14f88ba63a2cccc2.tar.xz third_party-ruby-git-779f21b307e7c119a56700fb14f88ba63a2cccc2.zip |
Merge branches 'master' and 'internals'
Diffstat (limited to 'lib/git/raw/internal/object.rb')
-rw-r--r-- | lib/git/raw/internal/object.rb | 37 |
1 files changed, 37 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..172b917 --- /dev/null +++ b/lib/git/raw/internal/object.rb @@ -0,0 +1,37 @@ +# +# converted from the gitrb project +# +# authors: +# Matthias Lederhofer <matled@gmx.net> +# Simon 'corecode' Schubert <corecode@fs.ei.tum.de> +# +# provides native ruby access to git objects and pack files +# + +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 +end |