diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-21 16:25:59 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-09-21 16:25:59 +0200 |
commit | 3a001a929064f615eda8fe935c6359381db21ddd (patch) | |
tree | efc8fb032a7a690fba44678ef2493efbd690011a /app/models | |
parent | abaa65efc1f912ffef05ccaf1e92dc009f828278 (diff) | |
download | gitlab-ce-3a001a929064f615eda8fe935c6359381db21ddd.tar.gz |
Fetch merge request ref if it is missing when visit MR pagefix-mr-without-refs
This will fix merge problem for merge requests between forks created
before 8.0
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/merge_request.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 93faa133875..eb468c6cd53 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -433,10 +433,22 @@ class MergeRequest < ActiveRecord::Base target_project.repository.fetch_ref( source_project.repository.path_to_repo, "refs/heads/#{source_branch}", - "refs/merge-requests/#{iid}/head" + ref_path ) end + def ref_path + "refs/merge-requests/#{iid}/head" + end + + def ref_is_fetched? + File.exists?(File.join(project.repository.path_to_repo, ref_path)) + end + + def ensure_ref_fetched + fetch_ref unless ref_is_fetched? + end + def in_locked_state begin lock_mr |