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