summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-23 15:03:00 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-23 15:03:00 +0000
commit541f7675f9a72a7156811ccc6cd58171b7583934 (patch)
treeb91830a4984ede75c4b7732c6e55ed7ff3a0fc8d /lib
parent94f130cbfc0349c1b17d4882e7d5c367030b21d1 (diff)
parent555fd0cf4ab9474f84b3fcf4a4045fdac181b5f7 (diff)
downloadgitlab-ce-541f7675f9a72a7156811ccc6cd58171b7583934.tar.gz
Merge branch 'fix-diff-patch-public-mr' into 'master'
Fix downloading of patches on public merge requests when user logged out ### What does this MR do? This MR makes it possible to download a diff patch on a public merge request when a user is logged out. ### Why was this MR needed? An Error 500 would result when a user attempted to click on the "Email Patches" or "Plain Diff" button: ``` NoMethodError - undefined method `id' for nil:NilClass: lib/gitlab/backend/shell_env.rb:9:in `set_env' lib/gitlab/satellite/action.rb:20:in `in_locked_and_timed_satellite' lib/gitlab/satellite/merge_action.rb:49:in `diff_in_satellite' app/models/merge_request.rb:219:in `to_diff' app/controllers/projects/merge_requests_controller.rb:42:in `block (2 levels) in show' ``` ### What are the relevant issue numbers? * Closes #1225 * Closes #1854 (dup) * Closes #1858 (dup) See merge request !872
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/backend/shell_env.rb4
-rw-r--r--lib/gitlab/satellite/action.rb6
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/backend/shell_env.rb b/lib/gitlab/backend/shell_env.rb
index 044afb27f3f..17ec029eed4 100644
--- a/lib/gitlab/backend/shell_env.rb
+++ b/lib/gitlab/backend/shell_env.rb
@@ -6,7 +6,9 @@ module Gitlab
def set_env(user)
# Set GL_ID env variable
- ENV['GL_ID'] = "user-#{user.id}"
+ if user
+ ENV['GL_ID'] = "user-#{user.id}"
+ end
end
def reset_env
diff --git a/lib/gitlab/satellite/action.rb b/lib/gitlab/satellite/action.rb
index 4890ccf21e6..489070f1a3f 100644
--- a/lib/gitlab/satellite/action.rb
+++ b/lib/gitlab/satellite/action.rb
@@ -39,8 +39,10 @@ module Gitlab
def prepare_satellite!(repo)
project.satellite.clear_and_update!
- repo.config['user.name'] = user.name
- repo.config['user.email'] = user.email
+ if user
+ repo.config['user.name'] = user.name
+ repo.config['user.email'] = user.email
+ end
end
def default_options(options = {})