Commit 0c5795a49726402d2f2751d8b05d5bbb9dd23511
1 parent
5f4445c3
Exists in
master
and in
4 other branches
serialize parent_ids in commit
Showing
2 changed files
with
12 additions
and
19 deletions
Show diff stats
app/views/commits/_diffs.html.haml
@@ -17,14 +17,14 @@ | @@ -17,14 +17,14 @@ | ||
17 | - diffs.each_with_index do |diff, i| | 17 | - diffs.each_with_index do |diff, i| |
18 | - next if diff.diff.empty? | 18 | - next if diff.diff.empty? |
19 | - file = Tree.new(@repository, @commit.id, @ref, diff.new_path) | 19 | - file = Tree.new(@repository, @commit.id, @ref, diff.new_path) |
20 | - - file = (@commit.prev_commit.tree / diff.old_path) unless file | 20 | + - file = Tree.new(@repository, @commit.parent_id, @ref, diff.old_path) unless file |
21 | - next unless file | 21 | - next unless file |
22 | .file{id: "diff-#{i}"} | 22 | .file{id: "diff-#{i}"} |
23 | .header | 23 | .header |
24 | - if diff.deleted_file | 24 | - if diff.deleted_file |
25 | %span= diff.old_path | 25 | %span= diff.old_path |
26 | 26 | ||
27 | - - if @commit.prev_commit | 27 | + - if @commit.parent_ids.present? |
28 | = link_to project_tree_path(@project, tree_join(@commit.prev_commit_id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do | 28 | = link_to project_tree_path(@project, tree_join(@commit.prev_commit_id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do |
29 | View file @ | 29 | View file @ |
30 | %span.commit-short-id= @commit.short_id(6) | 30 | %span.commit-short-id= @commit.short_id(6) |
@@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
43 | - if file.text? | 43 | - if file.text? |
44 | = render "commits/text_file", diff: diff, index: i | 44 | = render "commits/text_file", diff: diff, index: i |
45 | - elsif file.image? | 45 | - elsif file.image? |
46 | - - old_file = (@commit.prev_commit.tree / diff.old_path) if !@commit.prev_commit.nil? | 46 | + - old_file = Tree.new(@repository, @commit.parent_id, @ref, diff.old_path) if @commit.parent_id |
47 | = render "commits/image", diff: diff, old_file: old_file, file: file, index: i | 47 | = render "commits/image", diff: diff, old_file: old_file, file: file, index: i |
48 | - else | 48 | - else |
49 | %p.nothing_here_message No preview for this file type | 49 | %p.nothing_here_message No preview for this file type |
lib/gitlab/git/commit.rb
@@ -5,8 +5,8 @@ module Gitlab | @@ -5,8 +5,8 @@ module Gitlab | ||
5 | module Git | 5 | module Git |
6 | class Commit | 6 | class Commit |
7 | attr_accessor :raw_commit, :head, :refs, | 7 | attr_accessor :raw_commit, :head, :refs, |
8 | - :sha, :authored_date, :committed_date, :message, | ||
9 | - :author_name, :author_email, | 8 | + :id, :authored_date, :committed_date, :message, |
9 | + :author_name, :author_email, :parent_ids, | ||
10 | :committer_name, :committer_email | 10 | :committer_name, :committer_email |
11 | 11 | ||
12 | delegate :parents, :diffs, :tree, :stats, :to_patch, | 12 | delegate :parents, :diffs, :tree, :stats, :to_patch, |
@@ -14,7 +14,7 @@ module Gitlab | @@ -14,7 +14,7 @@ module Gitlab | ||
14 | 14 | ||
15 | class << self | 15 | class << self |
16 | def serialize_keys | 16 | def serialize_keys |
17 | - %w(sha authored_date committed_date author_name author_email committer_name committer_email message) | 17 | + %w(id authored_date committed_date author_name author_email committer_name committer_email message parent_ids) |
18 | end | 18 | end |
19 | 19 | ||
20 | def find_or_first(repo, commit_id = nil, root_ref) | 20 | def find_or_first(repo, commit_id = nil, root_ref) |
@@ -88,8 +88,8 @@ module Gitlab | @@ -88,8 +88,8 @@ module Gitlab | ||
88 | @head = head | 88 | @head = head |
89 | end | 89 | end |
90 | 90 | ||
91 | - def id | ||
92 | - sha | 91 | + def sha |
92 | + id | ||
93 | end | 93 | end |
94 | 94 | ||
95 | def short_id(length = 10) | 95 | def short_id(length = 10) |
@@ -109,16 +109,8 @@ module Gitlab | @@ -109,16 +109,8 @@ module Gitlab | ||
109 | author_name != committer_name || author_email != committer_email | 109 | author_name != committer_name || author_email != committer_email |
110 | end | 110 | end |
111 | 111 | ||
112 | - def prev_commit | ||
113 | - @prev_commit ||= if parents.present? | ||
114 | - Commit.new(parents.first) | ||
115 | - else | ||
116 | - nil | ||
117 | - end | ||
118 | - end | ||
119 | - | ||
120 | - def prev_commit_id | ||
121 | - prev_commit.try :id | 112 | + def parent_id |
113 | + parent_ids.first | ||
122 | end | 114 | end |
123 | 115 | ||
124 | # Shows the diff between the commit's parent and the commit. | 116 | # Shows the diff between the commit's parent and the commit. |
@@ -164,7 +156,7 @@ module Gitlab | @@ -164,7 +156,7 @@ module Gitlab | ||
164 | 156 | ||
165 | def init_from_grit(grit) | 157 | def init_from_grit(grit) |
166 | @raw_commit = grit | 158 | @raw_commit = grit |
167 | - @sha = grit.sha | 159 | + @id = grit.id |
168 | @message = grit.message | 160 | @message = grit.message |
169 | @authored_date = grit.authored_date | 161 | @authored_date = grit.authored_date |
170 | @committed_date = grit.committed_date | 162 | @committed_date = grit.committed_date |
@@ -172,6 +164,7 @@ module Gitlab | @@ -172,6 +164,7 @@ module Gitlab | ||
172 | @author_email = grit.author.email | 164 | @author_email = grit.author.email |
173 | @committer_name = grit.committer.name | 165 | @committer_name = grit.committer.name |
174 | @committer_email = grit.committer.email | 166 | @committer_email = grit.committer.email |
167 | + @parent_ids = grit.parents.map(&:id) | ||
175 | end | 168 | end |
176 | 169 | ||
177 | def init_from_hash(hash) | 170 | def init_from_hash(hash) |