summaryrefslogtreecommitdiff
path: root/app/controllers/projects/merge_requests_controller.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-10-20 14:03:10 +0000
committerDouwe Maan <douwe@gitlab.com>2016-10-20 14:03:10 +0000
commit030c82267fab507999f914b9d9e88651f1b7966a (patch)
treeaf20532111cf5918a057136974dd2645ef09a943 /app/controllers/projects/merge_requests_controller.rb
parent607fb9b2710b182a9f7b52e53822e514a5a3502f (diff)
parent0bbfdde64d3de61df1f87e2394c0f459512c7f51 (diff)
downloadgitlab-ce-030c82267fab507999f914b9d9e88651f1b7966a.tar.gz
Merge branch '23341-fix-viewing-mr-from-deleted-project' into 'master'
Fix a 500 error viewing an MR with a deleted source project ## What does this MR do? Allows merged MRs to be shown without any 500 errors if the source project is removed ## Are there points in the code the reviewer needs to double check? https://gitlab.com/gitlab-org/gitlab-ce/commit/31c37c6c38258684fc92e0d91119c33872e39034 fixed this for closed MRs only. I had trouble understanding the introduced helper and logic, so reverted it and keyed everything on the existence of the source project or branch directly. commits.json returns a 500 error for a closed or merged MR; the approach taken in the above MR was to hide the commits... tab, so I've run with that. For merged MRs, the commits (but not the pipeline data) are in the target project, so we *could* do better, but it's a fairly nasty intervention to make it happen. ## Why was this MR needed? Viewing merged MRs should work even if the fork they came from has been deleted or unlinked. ## Screenshots (if relevant) ![Screen_Shot_2016-10-19_at_17.56.37](/uploads/1aeadd5147b9a4ad29b946b1c7ea52cb/Screen_Shot_2016-10-19_at_17.56.37.png) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG.md) entry added - [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [x] API support added - Tests - [x] Added for this feature/bug - [ ] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if it does - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Closes #23341 See merge request !6991
Diffstat (limited to 'app/controllers/projects/merge_requests_controller.rb')
-rw-r--r--app/controllers/projects/merge_requests_controller.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 0f593d1a936..2ee53f7ceda 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -398,7 +398,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
status ||= "preparing"
else
- ci_service = @merge_request.source_project.ci_service
+ ci_service = @merge_request.source_project.try(:ci_service)
status = ci_service.commit_status(merge_request.diff_head_sha, merge_request.source_branch) if ci_service
if ci_service.respond_to?(:commit_coverage)
@@ -554,7 +554,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def define_pipelines_vars
@pipelines = @merge_request.all_pipelines
- if @pipelines.any?
+ if @pipelines.present?
@pipeline = @pipelines.first
@statuses = @pipeline.statuses.relevant
end