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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
830940f4
Commit
830940f4
authored
Jul 17, 2018
by
Jacob Vosmaer (GitLab)
Committed by
Sean McGivern
Jul 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate merge base, merged branches, write ref
parent
c093193b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
73 deletions
+12
-73
app/models/project.rb
app/models/project.rb
+6
-4
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+6
-69
No files found.
app/models/project.rb
View file @
830940f4
...
...
@@ -2171,12 +2171,14 @@ class Project < ActiveRecord::Base
merge_requests
=
source_of_merge_requests
.
opened
.
where
(
allow_collaboration:
true
)
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
if
branch_name
merge_requests
.
find_by
(
source_branch:
branch_name
)
&
.
can_be_merged_by?
(
user
)
else
merge_requests
.
any?
{
|
merge_request
|
merge_request
.
can_be_merged_by?
(
user
)
}
end
end
end
if
RequestStore
.
active?
RequestStore
.
fetch
(
"project-
#{
id
}
:branch-
#{
branch_name
}
:user-
#{
user
.
id
}
:branch_allows_collaboration"
)
do
...
...
lib/gitlab/git/repository.rb
View file @
830940f4
...
...
@@ -443,12 +443,8 @@ module Gitlab
# Returns the SHA of the most recent common ancestor of +from+ and +to+
def
merge_base
(
from
,
to
)
gitaly_migrate
(
:merge_base
)
do
|
is_enabled
|
if
is_enabled
wrapped_gitaly_errors
do
gitaly_repository_client
.
find_merge_base
(
from
,
to
)
else
rugged_merge_base
(
from
,
to
)
end
end
end
...
...
@@ -464,12 +460,8 @@ module Gitlab
return
[]
unless
root_sha
branches
=
gitaly_migrate
(
:merged_branch_names
)
do
|
is_enabled
|
if
is_enabled
branches
=
wrapped_gitaly_errors
do
gitaly_merged_branch_names
(
branch_names
,
root_sha
)
else
git_merged_branch_names
(
branch_names
,
root_sha
)
end
end
Set
.
new
(
branches
)
...
...
@@ -848,12 +840,8 @@ module Gitlab
def
write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
ref_path
=
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
ref_path
}
"
unless
ref_path
.
start_with?
(
"refs/"
)
||
ref_path
==
"HEAD"
gitaly_migrate
(
:write_ref
)
do
|
is_enabled
|
if
is_enabled
wrapped_gitaly_errors
do
gitaly_repository_client
.
write_ref
(
ref_path
,
ref
,
old_ref
,
shell
)
else
local_write_ref
(
ref_path
,
ref
,
old_ref:
old_ref
,
shell:
shell
)
end
end
end
...
...
@@ -1188,37 +1176,6 @@ module Gitlab
end
end
def
local_write_ref
(
ref_path
,
ref
,
old_ref:
nil
,
shell:
true
)
if
shell
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
else
rugged_write_ref
(
ref_path
,
ref
)
end
end
def
rugged_write_config
(
full_path
:)
rugged
.
config
[
'gitlab.fullpath'
]
=
full_path
end
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
raise
ArgumentError
,
"invalid ref_path
#{
ref_path
.
inspect
}
"
if
ref_path
.
include?
(
' '
)
raise
ArgumentError
,
"invalid ref
#{
ref
.
inspect
}
"
if
ref
.
include?
(
"
\x00
"
)
raise
ArgumentError
,
"invalid old_ref
#{
old_ref
.
inspect
}
"
if
!
old_ref
.
nil?
&&
old_ref
.
include?
(
"
\x00
"
)
input
=
"update
#{
ref_path
}
\x00
#{
ref
}
\x00
#{
old_ref
}
\x00
"
run_git!
(
%w[update-ref --stdin -z]
)
{
|
stdin
|
stdin
.
write
(
input
)
}
end
def
rugged_write_ref
(
ref_path
,
ref
)
rugged
.
references
.
create
(
ref_path
,
ref
,
force:
true
)
rescue
Rugged
::
ReferenceError
=>
ex
Rails
.
logger
.
error
"Unable to create
#{
ref_path
}
reference for repository
#{
path
}
:
#{
ex
}
"
rescue
Rugged
::
OSError
=>
ex
raise
unless
ex
.
message
=~
/Failed to create locked file/
&&
ex
.
message
=~
/File exists/
Rails
.
logger
.
error
"Unable to create
#{
ref_path
}
reference for repository
#{
path
}
:
#{
ex
}
"
end
def
run_git
(
args
,
chdir:
path
,
env:
{},
nice:
false
,
lazy_block:
nil
,
&
block
)
cmd
=
[
Gitlab
.
config
.
git
.
bin_path
,
*
args
]
cmd
.
unshift
(
"nice"
)
if
nice
...
...
@@ -1289,20 +1246,6 @@ module Gitlab
}
end
def
git_merged_branch_names
(
branch_names
,
root_sha
)
git_arguments
=
%W[branch --merged
#{
root_sha
}
--format=%(refname:short)
\
%(objectname)]
+
branch_names
lines
=
run_git
(
git_arguments
).
first
.
lines
lines
.
each_with_object
([])
do
|
line
,
branches
|
name
,
sha
=
line
.
strip
.
split
(
' '
,
2
)
branches
<<
name
if
sha
!=
root_sha
end
end
def
gitaly_merged_branch_names
(
branch_names
,
root_sha
)
qualified_branch_names
=
branch_names
.
map
{
|
b
|
"refs/heads/
#{
b
}
"
}
...
...
@@ -1448,12 +1391,6 @@ module Gitlab
raise
CommandError
,
@gitlab_projects
.
output
end
def
rugged_merge_base
(
from
,
to
)
rugged
.
merge_base
(
from
,
to
)
rescue
Rugged
::
ReferenceError
nil
end
def
rev_list_param
(
spec
)
spec
==
:all
?
[
'--all'
]
:
spec
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