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
5d6d05ee
Commit
5d6d05ee
authored
May 06, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
3d1a2a44
02ca1577
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
3 deletions
+86
-3
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+6
-0
lib/gitlab/gitaly_client/repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+8
-0
spec/lib/gitlab/git/object_pool_spec.rb
spec/lib/gitlab/git/object_pool_spec.rb
+3
-3
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+39
-0
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+30
-0
No files found.
lib/gitlab/git/repository.rb
View file @
5d6d05ee
...
...
@@ -922,6 +922,12 @@ module Gitlab
end
end
def
disconnect_alternates
wrapped_gitaly_errors
do
gitaly_repository_client
.
disconnect_alternates
end
end
def
gitaly_repository
Gitlab
::
GitalyClient
::
Util
.
repository
(
@storage
,
@relative_path
,
@gl_repository
,
@gl_project_path
)
end
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
5d6d05ee
...
...
@@ -331,6 +331,14 @@ module Gitlab
search_results_from_response
(
response
)
end
def
disconnect_alternates
request
=
Gitaly
::
DisconnectGitAlternatesRequest
.
new
(
repository:
@gitaly_repo
)
GitalyClient
.
call
(
@storage
,
:object_pool_service
,
:disconnect_git_alternates
,
request
)
end
private
def
search_results_from_response
(
gitaly_response
)
...
...
spec/lib/gitlab/git/object_pool_spec.rb
View file @
5d6d05ee
...
...
@@ -7,8 +7,6 @@ describe Gitlab::Git::ObjectPool do
let
(
:pool_repository
)
{
create
(
:pool_repository
)
}
let
(
:source_repository
)
{
pool_repository
.
source_project
.
repository
}
let
(
:source_repository_path
)
{
File
.
join
(
TestEnv
.
repos_path
,
source_repository
.
relative_path
)
}
let
(
:source_repository_rugged
)
{
Rugged
::
Repository
.
new
(
source_repository_path
)
}
subject
{
pool_repository
.
object_pool
}
...
...
@@ -82,6 +80,8 @@ describe Gitlab::Git::ObjectPool do
end
describe
'#fetch'
do
let
(
:source_repository_path
)
{
File
.
join
(
TestEnv
.
repos_path
,
source_repository
.
relative_path
)
}
let
(
:source_repository_rugged
)
{
Rugged
::
Repository
.
new
(
source_repository_path
)
}
let
(
:commit_count
)
{
source_repository
.
commit_count
}
context
"when the object's pool repository exists"
do
...
...
@@ -98,7 +98,7 @@ describe Gitlab::Git::ObjectPool do
it
"re-creates the object pool's repository"
do
subject
.
fetch
expect
(
subject
.
repository
.
exists?
).
to
be
(
true
)
expect
(
subject
.
repository
.
exists?
).
to
be
true
end
it
'does not raise an error'
do
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
5d6d05ee
...
...
@@ -2215,4 +2215,43 @@ describe Gitlab::Git::Repository, :seed_helper do
line
.
split
(
"
\t
"
).
last
end
end
describe
'#disconnect_alternates'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pool_repository
)
{
create
(
:pool_repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:repository_path
)
{
File
.
join
(
TestEnv
.
repos_path
,
repository
.
relative_path
)
}
let
(
:object_pool
)
{
pool_repository
.
object_pool
}
let
(
:object_pool_path
)
{
File
.
join
(
TestEnv
.
repos_path
,
object_pool
.
repository
.
relative_path
)
}
let
(
:object_pool_rugged
)
{
Rugged
::
Repository
.
new
(
object_pool_path
)
}
before
do
object_pool
.
create
end
it
'does not raise an error when disconnecting a non-linked repository'
do
expect
{
repository
.
disconnect_alternates
}.
not_to
raise_error
end
it
'removes the alternates file'
do
object_pool
.
link
(
repository
)
alternates_file
=
File
.
join
(
repository_path
,
"objects"
,
"info"
,
"alternates"
)
expect
(
File
.
exist?
(
alternates_file
)).
to
be_truthy
repository
.
disconnect_alternates
expect
(
File
.
exist?
(
alternates_file
)).
to
be_falsey
end
it
'can still access objects in the object pool'
do
object_pool
.
link
(
repository
)
new_commit
=
new_commit_edit_old_file
(
object_pool_rugged
)
expect
(
repository
.
commit
(
new_commit
.
oid
).
id
).
to
eq
(
new_commit
.
oid
)
repository
.
disconnect_alternates
expect
(
repository
.
commit
(
new_commit
.
oid
).
id
).
to
eq
(
new_commit
.
oid
)
end
end
end
spec/lib/gitlab/gitaly_client/repository_service_spec.rb
View file @
5d6d05ee
...
...
@@ -231,4 +231,34 @@ describe Gitlab::GitalyClient::RepositoryService do
client
.
raw_changes_between
(
'deadbeef'
,
'deadpork'
)
end
end
describe
'#disconnect_alternates'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:repository_path
)
{
File
.
join
(
TestEnv
.
repos_path
,
repository
.
relative_path
)
}
let
(
:pool_repository
)
{
create
(
:pool_repository
)
}
let
(
:object_pool
)
{
pool_repository
.
object_pool
}
let
(
:object_pool_service
)
{
Gitlab
::
GitalyClient
::
ObjectPoolService
.
new
(
object_pool
)
}
before
do
object_pool_service
.
create
(
repository
)
object_pool_service
.
link_repository
(
repository
)
end
it
'deletes the alternates file'
do
repository
.
disconnect_alternates
alternates_file
=
File
.
join
(
repository_path
,
"objects"
,
"info"
,
"alternates"
)
expect
(
File
.
exist?
(
alternates_file
)).
to
be_falsey
end
context
'when called twice'
do
it
"doesn't raise an error"
do
repository
.
disconnect_alternates
expect
{
repository
.
disconnect_alternates
}.
not_to
raise_error
end
end
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