summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-01 15:08:41 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-07-01 15:08:41 +0000
commit804168e1def1204af712febb229f41a3865f085f (patch)
tree82acc4a9b19899888f0b7d9306571e4a36589397 /app/models
parent8969a8235c5276fda7200001bfc082a822ecbe4a (diff)
parentd24c40ec219d76e01e2fab5f6ebf431adae91bdd (diff)
downloadgitlab-ce-804168e1def1204af712febb229f41a3865f085f.tar.gz
Merge branch 'use-rugged-for-merge' into 'master'
Merge branches inside one repository using rugged instead of satellites Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> cc @rspeicher @DouweM See merge request !918
Diffstat (limited to 'app/models')
-rw-r--r--app/models/merge_request.rb15
-rw-r--r--app/models/repository.rb4
2 files changed, 16 insertions, 3 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 7ecdaf6b2e0..040ab0f4b0f 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -205,7 +205,20 @@ class MergeRequest < ActiveRecord::Base
end
def check_if_can_be_merged
- if Gitlab::Satellite::MergeAction.new(self.author, self).can_be_merged?
+ can_be_merged =
+ if for_fork?
+ Gitlab::Satellite::MergeAction.new(self.author, self).can_be_merged?
+ else
+ rugged = project.repository.rugged
+ our_commit = rugged.branches[target_branch].target
+ their_commit = rugged.branches[source_branch].target
+
+ if our_commit && their_commit
+ !rugged.merge_commits(our_commit, their_commit).conflicts?
+ end
+ end
+
+ if can_be_merged
mark_as_mergeable
else
mark_as_unmergeable
diff --git a/app/models/repository.rb b/app/models/repository.rb
index cab3e896159..97d2aa1c89e 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -414,8 +414,6 @@ class Repository
Gitlab::Git::Blob.remove(raw_repository, options)
end
- private
-
def user_to_comitter(user)
{
email: user.email,
@@ -424,6 +422,8 @@ class Repository
}
end
+ private
+
def cache
@cache ||= RepositoryCache.new(path_with_namespace)
end