gitlabhq/app/contexts/commit_load_context.rb

35 lines
893 B
Ruby
Raw Normal View History

class CommitLoadContext < BaseContext
def execute
result = {
commit: nil,
suppress_diff: false,
line_notes: [],
notes_count: 0,
note: nil,
2012-08-11 14:59:36 +02:00
status: :ok
}
2013-01-03 20:09:18 +01:00
commit = project.repository.commit(params[:id])
if commit
commit = Commit.new(commit)
commit = CommitDecorator.decorate(commit)
2013-01-05 12:11:15 +01:00
line_notes = project.notes.for_commit_id(commit.id).inline
result[:commit] = commit
result[:note] = project.build_commit_note(commit)
result[:line_notes] = line_notes
2013-01-05 12:11:15 +01:00
result[:notes_count] = project.notes.for_commit_id(commit.id).count
2012-08-11 14:59:36 +02:00
begin
result[:suppress_diff] = true if commit.diffs.size > Commit::DIFF_SAFE_SIZE && !params[:force_show_diff]
2012-08-11 14:59:36 +02:00
rescue Grit::Git::GitTimeout
result[:suppress_diff] = true
result[:status] = :huge_commit
end
end
result
end
end