Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
11191f93
Commit
11191f93
authored
Jan 29, 2018
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Repository#can_be_merged? to Gitlab::Git::Repository
Fixes #42544
parent
44edd111
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
app/models/repository.rb
app/models/repository.rb
+1
-19
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+18
-0
No files found.
app/models/repository.rb
View file @
11191f93
...
@@ -800,16 +800,6 @@ class Repository
...
@@ -800,16 +800,6 @@ class Repository
with_cache_hooks
{
raw
.
multi_action
(
user
,
**
options
)
}
with_cache_hooks
{
raw
.
multi_action
(
user
,
**
options
)
}
end
end
def
can_be_merged?
(
source_sha
,
target_branch
)
raw_repository
.
gitaly_migrate
(
:can_be_merged
)
do
|
is_enabled
|
if
is_enabled
gitaly_can_be_merged?
(
source_sha
,
find_branch
(
target_branch
).
target
)
else
rugged_can_be_merged?
(
source_sha
,
target_branch
)
end
end
end
def
merge
(
user
,
source_sha
,
merge_request
,
message
)
def
merge
(
user
,
source_sha
,
merge_request
,
message
)
with_cache_hooks
do
with_cache_hooks
do
raw_repository
.
merge
(
user
,
source_sha
,
merge_request
.
target_branch
,
message
)
do
|
commit_id
|
raw_repository
.
merge
(
user
,
source_sha
,
merge_request
.
target_branch
,
message
)
do
|
commit_id
|
...
@@ -876,7 +866,7 @@ class Repository
...
@@ -876,7 +866,7 @@ class Repository
@root_ref_sha
||=
commit
(
root_ref
).
sha
@root_ref_sha
||=
commit
(
root_ref
).
sha
end
end
delegate
:merged_branch_names
,
to: :raw_repository
delegate
:merged_branch_names
,
:can_be_merged?
,
to: :raw_repository
def
merge_base
(
first_commit_id
,
second_commit_id
)
def
merge_base
(
first_commit_id
,
second_commit_id
)
first_commit_id
=
commit
(
first_commit_id
).
try
(
:id
)
||
first_commit_id
first_commit_id
=
commit
(
first_commit_id
).
try
(
:id
)
||
first_commit_id
...
@@ -1095,12 +1085,4 @@ class Repository
...
@@ -1095,12 +1085,4 @@ class Repository
def
initialize_raw_repository
def
initialize_raw_repository
Gitlab
::
Git
::
Repository
.
new
(
project
.
repository_storage
,
disk_path
+
'.git'
,
Gitlab
::
GlRepository
.
gl_repository
(
project
,
is_wiki
))
Gitlab
::
Git
::
Repository
.
new
(
project
.
repository_storage
,
disk_path
+
'.git'
,
Gitlab
::
GlRepository
.
gl_repository
(
project
,
is_wiki
))
end
end
def
gitaly_can_be_merged?
(
their_commit
,
our_commit
)
!
raw_repository
.
gitaly_conflicts_client
(
our_commit
,
their_commit
).
conflicts?
end
def
rugged_can_be_merged?
(
their_commit
,
our_commit
)
!
rugged
.
merge_commits
(
our_commit
,
their_commit
).
conflicts?
end
end
end
lib/gitlab/git/repository.rb
View file @
11191f93
...
@@ -1392,6 +1392,16 @@ module Gitlab
...
@@ -1392,6 +1392,16 @@ module Gitlab
run_git
(
args
).
first
.
scrub
.
split
(
/^--$/
)
run_git
(
args
).
first
.
scrub
.
split
(
/^--$/
)
end
end
def
can_be_merged?
(
source_sha
,
target_branch
)
gitaly_migrate
(
:can_be_merged
)
do
|
is_enabled
|
if
is_enabled
gitaly_can_be_merged?
(
source_sha
,
find_branch
(
target_branch
,
true
).
target
)
else
rugged_can_be_merged?
(
source_sha
,
target_branch
)
end
end
end
def
search_files_by_name
(
query
,
ref
)
def
search_files_by_name
(
query
,
ref
)
safe_query
=
Regexp
.
escape
(
query
.
sub
(
/^\/*/
,
""
))
safe_query
=
Regexp
.
escape
(
query
.
sub
(
/^\/*/
,
""
))
...
@@ -2234,6 +2244,14 @@ module Gitlab
...
@@ -2234,6 +2244,14 @@ module Gitlab
run_git
([
'fetch'
,
remote_name
],
env:
env
).
last
.
zero?
run_git
([
'fetch'
,
remote_name
],
env:
env
).
last
.
zero?
end
end
def
gitaly_can_be_merged?
(
their_commit
,
our_commit
)
!
gitaly_conflicts_client
(
our_commit
,
their_commit
).
conflicts?
end
def
rugged_can_be_merged?
(
their_commit
,
our_commit
)
!
rugged
.
merge_commits
(
our_commit
,
their_commit
).
conflicts?
end
def
gitlab_projects_error
def
gitlab_projects_error
raise
CommandError
,
@gitlab_projects
.
output
raise
CommandError
,
@gitlab_projects
.
output
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment