Commit 63e532eff01ac927e7fa39781d9ebd61503c9a3e

Authored by Dmitriy Zaporozhets
1 parent 967d42e0

Cache MR diffs result. Improve diff output

Procfile
1   -web: bundle exec puma -p $PORT
  1 +web: bundle exec unicorn_rails -p $PORT -E development
2 2 worker: bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default,gitlab_shell
... ...
app/controllers/projects/merge_requests_controller.rb
... ... @@ -30,7 +30,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
30 30 end
31 31  
32 32 def diffs
33   - @diffs = @merge_request.diffs
34 33 @commit = @merge_request.last_commit
35 34  
36 35 @comments_allowed = @reply_allowed = true
... ...
app/models/merge_request.rb
... ... @@ -116,7 +116,7 @@ class MergeRequest < ActiveRecord::Base
116 116 end
117 117  
118 118 def diffs
119   - load_diffs(st_diffs) || []
  119 + @diffs ||= (load_diffs(st_diffs) || [])
120 120 end
121 121  
122 122 def reloaded_diffs
... ... @@ -128,6 +128,8 @@ class MergeRequest < ActiveRecord::Base
128 128  
129 129 def broken_diffs?
130 130 diffs == broken_diffs
  131 + rescue
  132 + true
131 133 end
132 134  
133 135 def valid_diffs?
... ...
app/views/projects/merge_requests/_show.html.haml
... ... @@ -21,7 +21,8 @@
21 21 .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" }
22 22 = render "projects/notes/notes_with_form"
23 23 .diffs.tab-content
24   - = render "projects/merge_requests/show/diffs" if @diffs
  24 + - if current_page?(action: 'diffs')
  25 + = render "projects/merge_requests/show/diffs"
25 26 .status
26 27  
27 28 :javascript
... ...
app/views/projects/merge_requests/show/_diffs.html.haml
1 1 - if @merge_request.valid_diffs?
2   - = render "projects/commits/diffs", diffs: @diffs
  2 + = render "projects/commits/diffs", diffs: @merge_request.diffs
3 3 - elsif @merge_request.broken_diffs?
4 4 %h4.nothing_here_message
5 5 Can't load diff.
... ...
doc/install/installation.md
... ... @@ -184,11 +184,11 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version,
184 184 sudo chmod -R u+rwX public/uploads
185 185  
186 186 # Copy the example Puma config
187   - sudo -u git -H cp config/puma.rb.example config/puma.rb
  187 + sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
188 188  
189 189 # Enable cluster mode if you expect to have a high load instance
190 190 # Ex. change amount of workers to 3 for 2GB RAM server
191   - sudo -u git -H vim config/puma.rb
  191 + sudo -u git -H vim config/unicorn.rb
192 192  
193 193 # Configure Git global settings for git user, useful when editing via web
194 194 # Edit user.email according to what is set in gitlab.yml
... ... @@ -196,7 +196,7 @@ You can change `5-3-stable` to `master` if you want the *bleeding edge* version,
196 196 sudo -u git -H git config --global user.email "gitlab@localhost"
197 197  
198 198 **Important Note:**
199   -Make sure to edit both `gitlab.yml` and `puma.rb` to match your setup.
  199 +Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup.
200 200  
201 201 ## Configure GitLab DB settings
202 202  
... ...