summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-11-21 19:23:22 +0000
committerSean McGivern <sean@mcgivern.me.uk>2016-11-21 19:23:22 +0000
commit7a5e653fde62cfcd0e05be7954bbf14de0cb6d8c (patch)
treef7307706ea732f779b2cf4884b95bfbc1251a172 /app/services
parent06cf647c9b1936f55553b88f71c04cb593dfa7ae (diff)
parent35615bc33179a88c580cc28aca74c70754d21120 (diff)
downloadgitlab-ce-7a5e653fde62cfcd0e05be7954bbf14de0cb6d8c.tar.gz
Merge branch 'hide-empty-merge-request-diffs' into 'master'
Fix errors happening when source branch of merge request is removed and then restored See merge request !7568
Diffstat (limited to 'app/services')
-rw-r--r--app/services/merge_requests/refresh_service.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index 4a7e6930842..22596b4014a 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -60,7 +60,15 @@ module MergeRequests
merge_requests = filter_merge_requests(merge_requests)
merge_requests.each do |merge_request|
- reload_diff(merge_request) unless branch_removed?
+ if merge_request.source_branch == @branch_name || force_push?
+ merge_request.reload_diff
+ else
+ mr_commit_ids = merge_request.commits.map(&:id)
+ push_commit_ids = @commits.map(&:id)
+ matches = mr_commit_ids & push_commit_ids
+ merge_request.reload_diff if matches.any?
+ end
+
merge_request.mark_as_unchecked
end
end
@@ -165,16 +173,5 @@ module MergeRequests
def branch_removed?
Gitlab::Git.blank_ref?(@newrev)
end
-
- def reload_diff(merge_request)
- if merge_request.source_branch == @branch_name || force_push?
- merge_request.reload_diff
- else
- mr_commit_ids = merge_request.commits.map(&:id)
- push_commit_ids = @commits.map(&:id)
- matches = mr_commit_ids & push_commit_ids
- merge_request.reload_diff if matches.any?
- end
- end
end
end