2012-10-09 21:09:46 +02:00
|
|
|
class CommitLoadContext < BaseContext
|
2012-07-20 07:39:34 +02:00
|
|
|
def execute
|
2012-10-09 21:09:46 +02:00
|
|
|
result = {
|
2012-08-11 00:07:50 +02:00
|
|
|
commit: nil,
|
|
|
|
suppress_diff: false,
|
|
|
|
line_notes: [],
|
|
|
|
notes_count: 0,
|
2012-10-09 21:09:46 +02:00
|
|
|
note: nil,
|
2012-08-11 14:59:36 +02:00
|
|
|
status: :ok
|
2012-07-20 07:39:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
commit = project.commit(params[:id])
|
|
|
|
|
2012-10-09 21:09:46 +02:00
|
|
|
if commit
|
2012-07-20 07:39:34 +02:00
|
|
|
commit = CommitDecorator.decorate(commit)
|
|
|
|
line_notes = project.commit_line_notes(commit)
|
|
|
|
|
|
|
|
result[:commit] = commit
|
|
|
|
result[:note] = project.build_commit_note(commit)
|
|
|
|
result[:line_notes] = line_notes
|
|
|
|
result[:notes_count] = line_notes.count + project.commit_notes(commit).count
|
2012-08-11 14:59:36 +02:00
|
|
|
|
|
|
|
begin
|
2012-10-25 11:16:14 +02:00
|
|
|
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
|
2012-07-20 07:39:34 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|