summaryrefslogtreecommitdiffstats
path: root/lib/git/lib.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-12 17:29:39 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-12 17:29:39 -0800
commit852a0e63d294de874c3311f5e7edf40e2f2ecd60 (patch)
treeb77a38e91156d5e330246a6111f0ee835c38a80b /lib/git/lib.rb
parentec59c5c7ee9fa3b5831ed0b5f713cee218480ea3 (diff)
downloadthird_party-ruby-git-852a0e63d294de874c3311f5e7edf40e2f2ecd60.tar.gz
third_party-ruby-git-852a0e63d294de874c3311f5e7edf40e2f2ecd60.tar.xz
third_party-ruby-git-852a0e63d294de874c3311f5e7edf40e2f2ecd60.zip
added a bunch of good stuff to the commit object
Diffstat (limited to 'lib/git/lib.rb')
-rw-r--r--lib/git/lib.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/git/lib.rb b/lib/git/lib.rb
index 575f0d7..13a3b4c 100644
--- a/lib/git/lib.rb
+++ b/lib/git/lib.rb
@@ -79,6 +79,32 @@ module Git
command('cat-file', ['-s', sha]).to_i
end
+ # returns useful array of raw commit object data
+ def commit_data(sha)
+ in_message = false
+
+ hsh = {'message' => '', 'parent' => []}
+ command_lines('cat-file', ['commit', sha.to_s]).each do |line|
+ if in_message
+ hsh['message'] += line + "\n"
+ end
+
+ if (line != '') && !in_message
+ data = line.split
+ key = data.shift
+ value = data.join(' ')
+ if key == 'parent'
+ hsh[key] << value
+ else
+ hsh[key] = value
+ end
+ else
+ in_message = true
+ end
+ end
+ hsh
+ end
+
def object_contents(sha)
command('cat-file', ['-p', sha])
end