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
dfe79b3f
Commit
dfe79b3f
authored
Dec 17, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
3f2dbe0e
0ab50681
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
73 deletions
+63
-73
app/controllers/projects/settings/repository_controller.rb
app/controllers/projects/settings/repository_controller.rb
+0
-5
app/views/projects/cleanup/_show.html.haml
app/views/projects/cleanup/_show.html.haml
+0
-2
lib/gitlab/gitaly_client/cleanup_service.rb
lib/gitlab/gitaly_client/cleanup_service.rb
+1
-0
spec/controllers/projects/settings/repository_controller_spec.rb
...ntrollers/projects/settings/repository_controller_spec.rb
+5
-25
spec/features/projects/settings/repository_settings_spec.rb
spec/features/projects/settings/repository_settings_spec.rb
+9
-23
spec/lib/gitlab/git/repository_cleaner_spec.rb
spec/lib/gitlab/git/repository_cleaner_spec.rb
+48
-18
No files found.
app/controllers/projects/settings/repository_controller.rb
View file @
dfe79b3f
...
...
@@ -5,7 +5,6 @@ module Projects
class
RepositoryController
<
Projects
::
ApplicationController
before_action
:authorize_admin_project!
before_action
:remote_mirror
,
only:
[
:show
]
before_action
:check_cleanup_feature_flag!
,
only: :cleanup
prepend
::
EE
::
Projects
::
Settings
::
RepositoryController
...
...
@@ -39,10 +38,6 @@ module Projects
private
def
check_cleanup_feature_flag!
render_404
unless
::
Feature
.
enabled?
(
:project_cleanup
,
project
)
end
def
render_show
@deploy_keys
=
DeployKeysPresenter
.
new
(
@project
,
current_user:
current_user
)
@deploy_tokens
=
@project
.
deploy_tokens
.
active
...
...
app/views/projects/cleanup/_show.html.haml
View file @
dfe79b3f
-
return
unless
Feature
.
enabled?
(
:project_cleanup
,
@project
)
-
expanded
=
Rails
.
env
.
test?
%section
.settings.no-animate
#cleanup
{
class:
(
'expanded'
if
expanded
)
}
...
...
lib/gitlab/gitaly_client/cleanup_service.rb
View file @
dfe79b3f
...
...
@@ -20,6 +20,7 @@ module Gitlab
while
data
=
io
.
read
(
RepositoryService
::
MAX_MSG_SIZE
)
y
.
yield
Gitaly
::
ApplyBfgObjectMapRequest
.
new
(
object_map:
data
)
break
if
io
&
.
eof?
end
end
...
...
spec/controllers/projects/settings/repository_controller_spec.rb
View file @
dfe79b3f
...
...
@@ -19,35 +19,15 @@ describe Projects::Settings::RepositoryController do
end
describe
'PUT cleanup'
do
before
do
allow
(
RepositoryCleanupWorker
).
to
receive
(
:perform_async
)
end
def
do_put!
object_map
=
fixture_file_upload
(
'spec/fixtures/bfg_object_map.txt'
)
let
(
:object_map
)
{
fixture_file_upload
(
'spec/fixtures/bfg_object_map.txt'
)
}
put
:cleanup
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project:
{
object_map:
object_map
}
end
context
'feature enabled'
do
it
'enqueues a RepositoryCleanupWorker'
do
stub_feature_flags
(
project_cleanup:
true
)
allow
(
RepositoryCleanupWorker
).
to
receive
(
:perform_async
)
do_put!
put
:cleanup
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project:
{
object_map:
object_map
}
expect
(
response
).
to
redirect_to
project_settings_repository_path
(
project
)
expect
(
RepositoryCleanupWorker
).
to
have_received
(
:perform_async
).
once
end
end
context
'feature disabled'
do
it
'shows a 404 error'
do
stub_feature_flags
(
project_cleanup:
false
)
do_put!
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
spec/features/projects/settings/repository_settings_spec.rb
View file @
dfe79b3f
...
...
@@ -200,10 +200,7 @@ describe 'Projects > Settings > Repository settings' do
context
'repository cleanup settings'
do
let
(
:object_map_file
)
{
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'bfg_object_map.txt'
)
}
context
'feature enabled'
do
it
'uploads an object map file'
,
:js
do
stub_feature_flags
(
project_cleanup:
true
)
visit
project_settings_repository_path
(
project
)
expect
(
page
).
to
have_content
(
'Repository cleanup'
)
...
...
@@ -220,16 +217,5 @@ describe 'Projects > Settings > Repository settings' do
expect
(
RepositoryCleanupWorker
.
jobs
.
count
).
to
eq
(
1
)
end
end
context
'feature disabled'
do
it
'does not show the settings'
do
stub_feature_flags
(
project_cleanup:
false
)
visit
project_settings_repository_path
(
project
)
expect
(
page
).
not_to
have_content
(
'Repository cleanup'
)
end
end
end
end
end
spec/lib/gitlab/git/repository_cleaner_spec.rb
View file @
dfe79b3f
require
'spec_helper'
describe
Gitlab
::
Git
::
RepositoryCleaner
do
include
HttpIOHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:head_sha
)
{
repository
.
head_commit
.
id
}
let
(
:object_map
)
{
StringIO
.
new
(
"
#{
head_sha
}
#{
'0'
*
40
}
"
)
}
let
(
:object_map_data
)
{
"
#{
head_sha
}
#{
'0'
*
40
}
"
}
subject
(
:cleaner
)
{
described_class
.
new
(
repository
.
raw
)
}
describe
'#apply_bfg_object_map'
do
it
'removes internal references pointing at SHAs in the object map'
do
# Create some refs we expect to be removed
repository
.
keep_around
(
head_sha
)
repository
.
create_ref
(
head_sha
,
'refs/environments/1'
)
repository
.
create_ref
(
head_sha
,
'refs/merge-requests/1'
)
repository
.
create_ref
(
head_sha
,
'refs/heads/_keep'
)
repository
.
create_ref
(
head_sha
,
'refs/tags/_keep'
)
let
(
:clean_refs
)
{
%W[refs/environments/1 refs/merge-requests/1 refs/keep-around/
#{
head_sha
}
]
}
let
(
:keep_refs
)
{
%w[refs/heads/_keep refs/tags/_keep]
}
before
do
(
clean_refs
+
keep_refs
).
each
{
|
ref
|
repository
.
create_ref
(
head_sha
,
ref
)
}
end
context
'from StringIO'
do
let
(
:object_map
)
{
StringIO
.
new
(
object_map_data
)
}
it
'removes internal references'
do
cleaner
.
apply_bfg_object_map
(
object_map
)
aggregate_failures
do
expect
(
repository
.
kept_around?
(
head_sha
)).
to
be_falsy
expect
(
repository
.
ref_exists?
(
'refs/environments/1'
)).
to
be_falsy
expect
(
repository
.
ref_exists?
(
'refs/merge-requests/1'
)).
to
be_falsy
expect
(
repository
.
ref_exists?
(
'refs/heads/_keep'
)).
to
be_truthy
expect
(
repository
.
ref_exists?
(
'refs/tags/_keep'
)).
to
be_truthy
clean_refs
.
each
{
|
ref
|
expect
(
repository
.
ref_exists?
(
ref
)).
to
be_falsy
}
keep_refs
.
each
{
|
ref
|
expect
(
repository
.
ref_exists?
(
ref
)).
to
be_truthy
}
end
end
end
context
'from Gitlab::HttpIO'
do
let
(
:url
)
{
'http://example.com/bfg_object_map.txt'
}
let
(
:tempfile
)
{
Tempfile
.
new
}
let
(
:object_map
)
{
Gitlab
::
HttpIO
.
new
(
url
,
object_map_data
.
size
)
}
around
do
|
example
|
begin
tempfile
.
write
(
object_map_data
)
tempfile
.
close
example
.
run
ensure
tempfile
.
unlink
end
end
it
'removes internal references'
do
stub_remote_url_200
(
url
,
tempfile
.
path
)
cleaner
.
apply_bfg_object_map
(
object_map
)
aggregate_failures
do
clean_refs
.
each
{
|
ref
|
expect
(
repository
.
ref_exists?
(
ref
)).
to
be_falsy
}
keep_refs
.
each
{
|
ref
|
expect
(
repository
.
ref_exists?
(
ref
)).
to
be_truthy
}
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