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
1897a4a6
Commit
1897a4a6
authored
Jan 30, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-01-30
# Conflicts: # qa/qa/page/menu/admin.rb [ci skip]
parents
7ffe28eb
69a3af73
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
146 additions
and
88 deletions
+146
-88
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+15
-5
app/models/repository.rb
app/models/repository.rb
+5
-62
lib/gitlab/git/diff.rb
lib/gitlab/git/diff.rb
+1
-1
lib/gitlab/git/operation_service.rb
lib/gitlab/git/operation_service.rb
+4
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+71
-18
qa/qa/page/group/show.rb
qa/qa/page/group/show.rb
+9
-1
qa/qa/page/menu/admin.rb
qa/qa/page/menu/admin.rb
+3
-0
scripts/lint-rugged
scripts/lint-rugged
+1
-0
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+12
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+25
-0
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
1897a4a6
...
...
@@ -12,11 +12,9 @@ module IssuableCollections
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def
set_issuables_index
@issuables
=
issuables_collection
@issuables
=
@issuables
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issuables
,
collection_type
)
@total_pages
=
issuable_page_count
@issuables
=
issuables_collection
set_pagination
return
if
redirect_out_of_range
(
@total_pages
)
if
params
[
:label_name
].
present?
...
...
@@ -35,14 +33,26 @@ module IssuableCollections
@users
.
push
(
author
)
if
author
end
end
def
set_pagination
return
if
pagination_disabled?
@issuables
=
@issuables
.
page
(
params
[
:page
])
@issuable_meta_data
=
issuable_meta_data
(
@issuables
,
collection_type
)
@total_pages
=
issuable_page_count
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def
pagination_disabled?
false
end
def
issuables_collection
finder
.
execute
.
preload
(
preload_for_collection
)
end
def
redirect_out_of_range
(
total_pages
)
return
false
if
total_pages
.
zero?
return
false
if
total_pages
.
nil?
||
total_pages
.
zero?
out_of_range
=
@issuables
.
current_page
>
total_pages
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
app/models/repository.rb
View file @
1897a4a6
...
...
@@ -498,7 +498,7 @@ class Repository
raw_repository
.
root_ref
else
# When the repo does not exist we raise this error so no data is cached.
raise
Rugged
::
ReferenceError
raise
Gitlab
::
Git
::
Repository
::
NoRepository
end
end
cache_method
:root_ref
...
...
@@ -532,11 +532,7 @@ class Repository
def
commit_count_for_ref
(
ref
)
return
0
unless
exists?
begin
cache
.
fetch
(
:"commit_count_
#{
ref
}
"
)
{
raw_repository
.
commit_count
(
ref
)
}
rescue
Rugged
::
ReferenceError
0
end
cache
.
fetch
(
:"commit_count_
#{
ref
}
"
)
{
raw_repository
.
commit_count
(
ref
)
}
end
delegate
:branch_names
,
to: :raw_repository
...
...
@@ -660,26 +656,14 @@ class Repository
end
def
last_commit_for_path
(
sha
,
path
)
raw_repository
.
gitaly_migrate
(
:last_commit_for_path
)
do
|
is_enabled
|
if
is_enabled
last_commit_for_path_by_gitaly
(
sha
,
path
)
else
last_commit_for_path_by_rugged
(
sha
,
path
)
end
end
commit_by
(
oid:
last_commit_id_for_path
(
sha
,
path
))
end
def
last_commit_id_for_path
(
sha
,
path
)
key
=
path
.
blank?
?
"last_commit_id_for_path:
#{
sha
}
"
:
"last_commit_id_for_path:
#{
sha
}
:
#{
Digest
::
SHA1
.
hexdigest
(
path
)
}
"
cache
.
fetch
(
key
)
do
raw_repository
.
gitaly_migrate
(
:last_commit_for_path
)
do
|
is_enabled
|
if
is_enabled
last_commit_for_path_by_gitaly
(
sha
,
path
).
id
else
last_commit_id_for_path_by_shelling_out
(
sha
,
path
)
end
end
raw_repository
.
last_commit_id_for_path
(
sha
,
path
)
end
end
...
...
@@ -807,16 +791,6 @@ class Repository
with_cache_hooks
{
raw
.
multi_action
(
user
,
**
options
)
}
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
)
with_cache_hooks
do
raw_repository
.
merge
(
user
,
source_sha
,
merge_request
.
target_branch
,
message
)
do
|
commit_id
|
...
...
@@ -931,20 +905,12 @@ class Repository
first_commit_id
=
commit
(
first_commit_id
).
try
(
:id
)
||
first_commit_id
second_commit_id
=
commit
(
second_commit_id
).
try
(
:id
)
||
second_commit_id
raw_repository
.
merge_base
(
first_commit_id
,
second_commit_id
)
rescue
Rugged
::
ReferenceError
nil
end
def
ancestor?
(
ancestor_id
,
descendant_id
)
return
false
if
ancestor_id
.
nil?
||
descendant_id
.
nil?
Gitlab
::
GitalyClient
.
migrate
(
:is_ancestor
)
do
|
is_enabled
|
if
is_enabled
raw_repository
.
ancestor?
(
ancestor_id
,
descendant_id
)
else
rugged_is_ancestor?
(
ancestor_id
,
descendant_id
)
end
end
raw_repository
.
ancestor?
(
ancestor_id
,
descendant_id
)
end
def
fetch_as_mirror
(
url
,
forced:
false
,
refmap: :all_refs
,
remote_name:
nil
)
...
...
@@ -1146,30 +1112,7 @@ class Repository
Gitlab
::
Metrics
.
add_event
(
event
,
{
path:
full_path
}.
merge
(
tags
))
end
def
last_commit_for_path_by_gitaly
(
sha
,
path
)
c
=
raw_repository
.
gitaly_commit_client
.
last_commit_for_path
(
sha
,
path
)
commit_by
(
oid:
c
)
end
def
last_commit_for_path_by_rugged
(
sha
,
path
)
sha
=
last_commit_id_for_path_by_shelling_out
(
sha
,
path
)
commit_by
(
oid:
sha
)
end
def
last_commit_id_for_path_by_shelling_out
(
sha
,
path
)
args
=
%W(rev-list --max-count=1
#{
sha
}
--
#{
path
}
)
raw_repository
.
run_git_with_timeout
(
args
,
Gitlab
::
Git
::
Popen
::
FAST_GIT_PROCESS_TIMEOUT
).
first
.
strip
end
def
initialize_raw_repository
Gitlab
::
Git
::
Repository
.
new
(
project
.
repository_storage
,
disk_path
+
'.git'
,
Gitlab
::
GlRepository
.
gl_repository
(
project
,
is_wiki
))
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
lib/gitlab/git/diff.rb
View file @
1897a4a6
...
...
@@ -44,7 +44,7 @@ module Gitlab
# branch1...branch2) From the git documentation:
# "git diff A...B" is equivalent to "git diff
# $(git-merge-base A B) B"
repo
.
merge_base
_commit
(
head
,
base
)
repo
.
merge_base
(
head
,
base
)
end
options
||=
{}
...
...
lib/gitlab/git/operation_service.rb
View file @
1897a4a6
...
...
@@ -131,7 +131,10 @@ module Gitlab
oldrev
=
branch
.
target
if
oldrev
==
repository
.
merge_base
(
newrev
,
branch
.
target
)
merge_base
=
repository
.
merge_base
(
newrev
,
branch
.
target
)
raise
Gitlab
::
Git
::
Repository
::
InvalidRef
unless
merge_base
if
oldrev
==
merge_base
oldrev
else
raise
Gitlab
::
Git
::
CommitError
.
new
(
'Branch diverged'
)
...
...
lib/gitlab/git/repository.rb
View file @
1897a4a6
...
...
@@ -551,29 +551,34 @@ module Gitlab
end
# Returns the SHA of the most recent common ancestor of +from+ and +to+
def
merge_base
_commit
(
from
,
to
)
def
merge_base
(
from
,
to
)
gitaly_migrate
(
:merge_base
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
find_merge_base
(
from
,
to
)
else
rugged
.
merge_base
(
from
,
to
)
rugged
_
merge_base
(
from
,
to
)
end
end
end
alias_method
:merge_base
,
:merge_base_commit
# Gitaly note: JV: check gitlab-ee before removing this method.
def
rugged_is_ancestor?
(
ancestor_id
,
descendant_id
)
return
false
if
ancestor_id
.
nil?
||
descendant_id
.
nil?
merge_base_commit
(
ancestor_id
,
descendant_id
)
==
ancestor_id
rugged_merge_base
(
ancestor_id
,
descendant_id
)
==
ancestor_id
rescue
Rugged
::
OdbError
false
end
# Returns true is +from+ is direct ancestor to +to+, otherwise false
def
ancestor?
(
from
,
to
)
gitaly_commit_client
.
ancestor?
(
from
,
to
)
Gitlab
::
GitalyClient
.
migrate
(
:is_ancestor
)
do
|
is_enabled
|
if
is_enabled
gitaly_commit_client
.
ancestor?
(
from
,
to
)
else
rugged_is_ancestor?
(
from
,
to
)
end
end
end
def
merged_branch_names
(
branch_names
=
[])
...
...
@@ -680,11 +685,7 @@ module Gitlab
if
is_enabled
gitaly_commit_client
.
commit_count
(
ref
)
else
walker
=
Rugged
::
Walker
.
new
(
rugged
)
walker
.
sorting
(
Rugged
::
SORT_TOPO
|
Rugged
::
SORT_REVERSE
)
oid
=
rugged
.
rev_parse_oid
(
ref
)
walker
.
push
(
oid
)
walker
.
count
rugged_commit_count
(
ref
)
end
end
end
...
...
@@ -1130,13 +1131,6 @@ module Gitlab
target_ref
end
# Refactoring aid; allows us to copy code from app/models/repository.rb
def
run_git_with_timeout
(
args
,
timeout
,
env:
{})
circuit_breaker
.
perform
do
popen_with_timeout
([
Gitlab
.
config
.
git
.
bin_path
,
*
args
],
timeout
,
path
,
env
)
end
end
# Refactoring aid; allows us to copy code from app/models/repository.rb
def
commit
(
ref
=
'HEAD'
)
Gitlab
::
Git
::
Commit
.
find
(
self
,
ref
)
...
...
@@ -1417,6 +1411,26 @@ module Gitlab
output
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
).
target
)
else
rugged_can_be_merged?
(
source_sha
,
target_branch
)
end
end
end
def
last_commit_id_for_path
(
sha
,
path
)
gitaly_migrate
(
:last_commit_for_path
)
do
|
is_enabled
|
if
is_enabled
last_commit_for_path_by_gitaly
(
sha
,
path
).
id
else
last_commit_id_for_path_by_shelling_out
(
sha
,
path
)
end
end
end
private
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
...
...
@@ -1460,6 +1474,12 @@ module Gitlab
output
end
def
run_git_with_timeout
(
args
,
timeout
,
env:
{})
circuit_breaker
.
perform
do
popen_with_timeout
([
Gitlab
.
config
.
git
.
bin_path
,
*
args
],
timeout
,
path
,
env
)
end
end
def
fresh_worktree?
(
path
)
File
.
exist?
(
path
)
&&
!
clean_stuck_worktree
(
path
)
end
...
...
@@ -2160,7 +2180,7 @@ module Gitlab
source_sha
end
rescue
Rugged
::
ReferenceError
rescue
Rugged
::
ReferenceError
,
InvalidRef
raise
ArgumentError
,
'Invalid merge source'
end
...
...
@@ -2257,6 +2277,39 @@ module Gitlab
.
commits_by_message
(
query
,
revision:
ref
,
path:
path
,
limit:
limit
,
offset:
offset
)
.
map
{
|
c
|
commit
(
c
)
}
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
last_commit_for_path_by_gitaly
(
sha
,
path
)
gitaly_commit_client
.
last_commit_for_path
(
sha
,
path
)
end
def
last_commit_id_for_path_by_shelling_out
(
sha
,
path
)
args
=
%W(rev-list --max-count=1
#{
sha
}
--
#{
path
}
)
run_git_with_timeout
(
args
,
Gitlab
::
Git
::
Popen
::
FAST_GIT_PROCESS_TIMEOUT
).
first
.
strip
end
def
rugged_merge_base
(
from
,
to
)
rugged
.
merge_base
(
from
,
to
)
rescue
Rugged
::
ReferenceError
nil
end
def
rugged_commit_count
(
ref
)
walker
=
Rugged
::
Walker
.
new
(
rugged
)
walker
.
sorting
(
Rugged
::
SORT_TOPO
|
Rugged
::
SORT_REVERSE
)
oid
=
rugged
.
rev_parse_oid
(
ref
)
walker
.
push
(
oid
)
walker
.
count
rescue
Rugged
::
ReferenceError
0
end
end
end
end
qa/qa/page/group/show.rb
View file @
1897a4a6
...
...
@@ -13,6 +13,10 @@ module QA
element
:new_subgroup_button
,
/%input.*\.js-new-group-child/
end
view
'app/assets/javascripts/groups/constants.js'
do
element
:no_result_text
,
'Sorry, no groups or projects matched your search'
end
def
go_to_subgroup
(
name
)
click_link
name
end
...
...
@@ -24,7 +28,11 @@ module QA
def
has_subgroup?
(
name
)
filter_by_name
(
name
)
page
.
has_link?
(
name
)
wait
(
reload:
false
)
do
return
false
if
page
.
has_content?
(
'Sorry, no groups or projects matched your search'
)
page
.
has_link?
(
name
)
end
end
def
go_to_new_subgroup
...
...
qa/qa/page/menu/admin.rb
View file @
1897a4a6
...
...
@@ -2,8 +2,11 @@ module QA
module
Page
module
Menu
class
Admin
<
Page
::
Base
<<<<<<<
HEAD
prepend
EE
::
Page
::
Menu
::
Admin
=======
>>>>>>>
upstream
/
master
view
'app/views/layouts/nav/sidebar/_admin.html.haml'
do
element
:settings
,
"_('Settings')"
end
...
...
scripts/lint-rugged
View file @
1897a4a6
...
...
@@ -24,6 +24,7 @@ ALLOWED = [
].
freeze
rugged_lines
=
IO
.
popen
(
%w[git grep -i -n rugged -- app config lib]
,
&
:read
).
lines
rugged_lines
=
rugged_lines
.
select
{
|
l
|
/^[^:]*\.rb:/
=~
l
}
rugged_lines
=
rugged_lines
.
reject
{
|
l
|
l
.
start_with?
(
*
ALLOWED
)
}
rugged_lines
=
rugged_lines
.
reject
do
|
line
|
code
,
_comment
=
line
.
split
(
'# '
,
2
)
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
1897a4a6
...
...
@@ -102,6 +102,18 @@ describe Projects::IssuesController do
expect
(
response
).
to
redirect_to
(
namespace_project_issues_path
(
page:
last_page
,
state:
controller
.
params
[
:state
],
scope:
controller
.
params
[
:scope
]))
end
it
'does not use pagination if disabled'
do
allow
(
controller
).
to
receive
(
:pagination_disabled?
).
and_return
(
true
)
get
:index
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
page:
(
last_page
+
1
).
to_param
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
assigns
(
:issues
).
size
).
to
eq
(
2
)
end
end
end
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
1897a4a6
...
...
@@ -2,6 +2,7 @@ require "spec_helper"
describe
Gitlab
::
Git
::
Repository
,
seed_helper:
true
do
include
Gitlab
::
EncodingHelper
using
RSpec
::
Parameterized
::
TableSyntax
shared_examples
'wrapping gRPC errors'
do
|
gitaly_client_class
,
gitaly_client_method
|
it
'wraps gRPC not found error'
do
...
...
@@ -442,6 +443,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
shared_examples
'simple commit counting'
do
it
{
expect
(
repository
.
commit_count
(
"master"
)).
to
eq
(
25
)
}
it
{
expect
(
repository
.
commit_count
(
"feature"
)).
to
eq
(
9
)
}
it
{
expect
(
repository
.
commit_count
(
"does-not-exist"
)).
to
eq
(
0
)
}
end
context
'when Gitaly commit_count feature is enabled'
do
...
...
@@ -1032,6 +1034,29 @@ describe Gitlab::Git::Repository, seed_helper: true do
it
{
is_expected
.
to
eq
(
17
)
}
end
describe
'#merge_base'
do
shared_examples
'#merge_base'
do
where
(
:from
,
:to
,
:result
)
do
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
|
'40f4a7a617393735a95a0bb67b08385bc1e7c66d'
|
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
'40f4a7a617393735a95a0bb67b08385bc1e7c66d'
|
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
|
'570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
'40f4a7a617393735a95a0bb67b08385bc1e7c66d'
|
'foobar'
|
nil
'foobar'
|
'40f4a7a617393735a95a0bb67b08385bc1e7c66d'
|
nil
end
with_them
do
it
{
expect
(
repository
.
merge_base
(
from
,
to
)).
to
eq
(
result
)
}
end
end
context
'with gitaly'
do
it_behaves_like
'#merge_base'
end
context
'without gitaly'
,
:skip_gitaly_mock
do
it_behaves_like
'#merge_base'
end
end
describe
'#count_commits'
do
shared_examples
'extended commit counting'
do
context
'with after timestamp'
do
...
...
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