From 3063af5adcf1c0331681fbbc13e679de1eb96487 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 20 Jul 2012 08:39:34 +0300 Subject: BaseContext Controllers refactoring with contexts Move commit compare logic to model --- app/contexts/commit_load.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/contexts/commit_load.rb (limited to 'app/contexts/commit_load.rb') diff --git a/app/contexts/commit_load.rb b/app/contexts/commit_load.rb new file mode 100644 index 00000000000..bab30d61007 --- /dev/null +++ b/app/contexts/commit_load.rb @@ -0,0 +1,26 @@ +class CommitLoad < BaseContext + def execute + result = { + :commit => nil, + :suppress_diff => false, + :line_notes => [], + :notes_count => 0, + :note => nil + } + + commit = project.commit(params[:id]) + + if commit + commit = CommitDecorator.decorate(commit) + line_notes = project.commit_line_notes(commit) + + result[:suppress_diff] = true if commit.diffs.size > 200 && !params[:force_show_diff] + 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 + end + + result + end +end -- cgit v1.2.1