BaseContext
Controllers refactoring with contexts Move commit compare logic to model
This commit is contained in:
parent
3c6daec4b1
commit
3063af5adc
11 changed files with 130 additions and 62 deletions
26
app/contexts/commit_load.rb
Normal file
26
app/contexts/commit_load.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue