diff options
author | Nick Thomas <nick@gitlab.com> | 2016-10-19 19:13:04 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2016-10-20 14:24:27 +0300 |
commit | 374071321d0cfb7a161ec38e85e27e1d46ae7c9a (patch) | |
tree | 4fd27bd59afc80546d09190e2245284942e080bd /app/models/merge_request.rb | |
parent | e6f515ecbed85b204e8f7bc9934b0bf208a0ea4c (diff) |
Fix the merge request view when source projects or branches are removed
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index d32bc9f882f..45fa8af60e5 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -333,7 +333,7 @@ class MergeRequest < ActiveRecord::Base end def closed_without_fork? - closed? && (forked_source_project_missing? || !source_project) + closed? && forked_source_project_missing? end def forked_source_project_missing? @@ -344,7 +344,7 @@ class MergeRequest < ActiveRecord::Base end def reopenable? - source_branch_exists? && closed? + closed? && !source_project_missing? && source_branch_exists? end def ensure_merge_request_diff @@ -656,7 +656,7 @@ class MergeRequest < ActiveRecord::Base end def has_ci? - source_project.ci_service && commits.any? + source_project.try(:ci_service) && commits.any? end def branch_missing? @@ -688,12 +688,9 @@ class MergeRequest < ActiveRecord::Base @environments ||= begin - environments = source_project.environments_for( - source_branch, diff_head_commit) - environments += target_project.environments_for( - target_branch, diff_head_commit, with_tags: true) - - environments.uniq + envs = target_project.environments_for(target_branch, diff_head_commit, with_tags: true) + envs.concat(source_project.environments_for(source_branch, diff_head_commit)) if source_project + envs.uniq end end |