diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-01-05 15:08:06 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-01-05 15:08:06 +0000 |
commit | 6eeb69fc9a216bd1874cba85214af5b1da1a46d0 (patch) | |
tree | 5def37365fe1296362791c709f48fc501a67a9cf /app/models | |
parent | 7d6a0a215806cbcbd7e1918ad042d554e3b6459f (diff) | |
parent | 27a75ea1757d1c1b67bf501ec333221ed5e92d04 (diff) | |
download | gitlab-ce-6eeb69fc9a216bd1874cba85214af5b1da1a46d0.tar.gz |
Merge branch 'jprovazn-rebase' into 'master'
Backport 'Rebase' feature from EE to CE
Closes #40301
See merge request gitlab-org/gitlab-ce!16071
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/merge_request.rb | 9 | ||||
-rw-r--r-- | app/models/repository.rb | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index c39789b047d..ef58816937c 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -156,6 +156,13 @@ class MergeRequest < ActiveRecord::Base '!' end + def rebase_in_progress? + # The source project can be deleted + return false unless source_project + + source_project.repository.rebase_in_progress?(id) + end + # Use this method whenever you need to make sure the head_pipeline is synced with the # branch head commit, for example checking if a merge request can be merged. # For more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/40004 @@ -607,7 +614,7 @@ class MergeRequest < ActiveRecord::Base check_if_can_be_merged - can_be_merged? + can_be_merged? && !should_be_rebased? end def mergeable_state?(skip_ci_check: false) diff --git a/app/models/repository.rb b/app/models/repository.rb index b1fd981965c..4bedcbfb6a2 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1099,6 +1099,13 @@ class Repository @project.repository_storage_path end + def rebase(user, merge_request) + raw.rebase(user, merge_request.id, branch: merge_request.source_branch, + branch_sha: merge_request.source_branch_sha, + remote_repository: merge_request.target_project.repository.raw, + remote_branch: merge_request.target_branch) + end + private # TODO Generice finder, later split this on finders by Ref or Oid |