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
d9f6d5dd
Commit
d9f6d5dd
authored
Jun 15, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not check repos without push events
parent
b2247398
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
app/workers/repository_check/single_repository_worker.rb
app/workers/repository_check/single_repository_worker.rb
+5
-1
spec/workers/repository_check/single_repository_worker_spec.rb
...workers/repository_check/single_repository_worker_spec.rb
+29
-0
No files found.
app/workers/repository_check/single_repository_worker.rb
View file @
d9f6d5dd
...
...
@@ -15,7 +15,7 @@ module RepositoryCheck
private
def
check
(
project
)
if
!
git_fsck
(
project
.
repository
)
if
has_pushes?
(
project
)
&&
!
git_fsck
(
project
.
repository
)
false
elsif
project
.
wiki_enabled?
# Historically some projects never had their wiki repos initialized;
...
...
@@ -44,5 +44,9 @@ module RepositoryCheck
false
end
end
def
has_pushes?
(
project
)
Project
.
with_push
.
exists?
(
project
.
id
)
end
end
end
spec/workers/repository_check/single_repository_worker_spec.rb
View file @
d9f6d5dd
...
...
@@ -4,6 +4,26 @@ require 'fileutils'
describe
RepositoryCheck
::
SingleRepositoryWorker
do
subject
{
described_class
.
new
}
it
'passes when the project has no push events'
do
project
=
create
(
:project_empty_repo
,
wiki_enabled:
false
)
project
.
events
.
destroy_all
break_repo
(
project
)
subject
.
perform
(
project
.
id
)
expect
(
project
.
reload
.
last_repository_check_failed
).
to
eq
(
false
)
end
it
'fails when the project has push events and a broken repository'
do
project
=
create
(
:project_empty_repo
)
create_push_event
(
project
)
break_repo
(
project
)
subject
.
perform
(
project
.
id
)
expect
(
project
.
reload
.
last_repository_check_failed
).
to
eq
(
true
)
end
it
'fails if the wiki repository is broken'
do
project
=
create
(
:project_empty_repo
,
wiki_enabled:
true
)
project
.
create_wiki
...
...
@@ -39,6 +59,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
it
'does not create a wiki if the main repo does not exist at all'
do
project
=
create
(
:project_empty_repo
)
create_push_event
(
project
)
FileUtils
.
rm_rf
(
project
.
repository
.
path_to_repo
)
FileUtils
.
rm_rf
(
wiki_path
(
project
))
...
...
@@ -54,4 +75,12 @@ describe RepositoryCheck::SingleRepositoryWorker do
def
wiki_path
(
project
)
project
.
wiki
.
repository
.
path_to_repo
end
def
create_push_event
(
project
)
project
.
events
.
create
(
action:
Event
::
PUSHED
,
author_id:
create
(
:user
).
id
)
end
def
break_repo
(
project
)
FileUtils
.
rm_rf
(
File
.
join
(
project
.
repository
.
path_to_repo
,
'objects'
))
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