diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-04-02 21:46:19 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-04-02 21:46:19 +0300 |
commit | 0c5795a49726402d2f2751d8b05d5bbb9dd23511 (patch) | |
tree | 1704887854916620a27f13311b80fa70188374bb /lib/gitlab/git | |
parent | 5f4445c3d384741c45242f077b3c0dbf76234ee8 (diff) | |
download | gitlab-ce-0c5795a49726402d2f2751d8b05d5bbb9dd23511.tar.gz |
serialize parent_ids in commit
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/commit.rb | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index c691ea3d223..b7c5558739b 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -5,8 +5,8 @@ module Gitlab module Git class Commit attr_accessor :raw_commit, :head, :refs, - :sha, :authored_date, :committed_date, :message, - :author_name, :author_email, + :id, :authored_date, :committed_date, :message, + :author_name, :author_email, :parent_ids, :committer_name, :committer_email delegate :parents, :diffs, :tree, :stats, :to_patch, @@ -14,7 +14,7 @@ module Gitlab class << self def serialize_keys - %w(sha authored_date committed_date author_name author_email committer_name committer_email message) + %w(id authored_date committed_date author_name author_email committer_name committer_email message parent_ids) end def find_or_first(repo, commit_id = nil, root_ref) @@ -88,8 +88,8 @@ module Gitlab @head = head end - def id - sha + def sha + id end def short_id(length = 10) @@ -109,16 +109,8 @@ module Gitlab author_name != committer_name || author_email != committer_email end - def prev_commit - @prev_commit ||= if parents.present? - Commit.new(parents.first) - else - nil - end - end - - def prev_commit_id - prev_commit.try :id + def parent_id + parent_ids.first end # Shows the diff between the commit's parent and the commit. @@ -164,7 +156,7 @@ module Gitlab def init_from_grit(grit) @raw_commit = grit - @sha = grit.sha + @id = grit.id @message = grit.message @authored_date = grit.authored_date @committed_date = grit.committed_date @@ -172,6 +164,7 @@ module Gitlab @author_email = grit.author.email @committer_name = grit.committer.name @committer_email = grit.committer.email + @parent_ids = grit.parents.map(&:id) end def init_from_hash(hash) |