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
4c8fe525
Commit
4c8fe525
authored
Aug 16, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor RepositoryUpdatedService initializer
So consumers don’t need to know about `source`.
parent
74d906ea
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
26 additions
and
29 deletions
+26
-29
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+2
-8
ee/app/models/ee/repository.rb
ee/app/models/ee/repository.rb
+5
-2
ee/app/services/ee/projects/update_service.rb
ee/app/services/ee/projects/update_service.rb
+1
-1
ee/app/services/ee/wiki_pages/base_service.rb
ee/app/services/ee/wiki_pages/base_service.rb
+1
-1
ee/app/services/geo/repository_updated_service.rb
ee/app/services/geo/repository_updated_service.rb
+3
-3
ee/app/workers/ee/post_receive.rb
ee/app/workers/ee/post_receive.rb
+2
-2
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+2
-2
ee/spec/services/geo/repository_updated_service_spec.rb
ee/spec/services/geo/repository_updated_service_spec.rb
+4
-4
ee/spec/services/wiki_pages/create_service_spec.rb
ee/spec/services/wiki_pages/create_service_spec.rb
+2
-2
ee/spec/services/wiki_pages/destroy_service_spec.rb
ee/spec/services/wiki_pages/destroy_service_spec.rb
+2
-2
ee/spec/services/wiki_pages/update_service_spec.rb
ee/spec/services/wiki_pages/update_service_spec.rb
+2
-2
No files found.
ee/app/models/ee/project.rb
View file @
4c8fe525
...
...
@@ -520,7 +520,8 @@ module EE
override
:after_import
def
after_import
super
log_geo_events
repository
.
log_geo_updated_event
wiki
.
repository
.
log_geo_updated_event
end
override
:import?
...
...
@@ -573,13 +574,6 @@ module EE
# Board limits are disabled in EE, so this method is just a no-op.
end
def
log_geo_events
return
unless
::
Gitlab
::
Geo
.
primary?
::
Geo
::
RepositoryUpdatedService
.
new
(
self
,
source:
::
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
).
execute
::
Geo
::
RepositoryUpdatedService
.
new
(
self
,
source:
::
Geo
::
RepositoryUpdatedEvent
::
WIKI
).
execute
end
override
:
after_rename_repository
def
after_rename_repository
(
full_path_before
,
path_before
)
super
(
full_path_before
,
path_before
)
...
...
ee/app/models/ee/repository.rb
View file @
4c8fe525
...
...
@@ -81,8 +81,11 @@ module EE
def
log_geo_updated_event
return
unless
::
Gitlab
::
Geo
.
primary?
source
=
is_wiki
?
::
Geo
::
RepositoryUpdatedEvent
::
WIKI
:
::
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
::
Geo
::
RepositoryUpdatedService
.
new
(
self
.
project
,
source:
source
).
execute
::
Geo
::
RepositoryUpdatedService
.
new
(
self
).
execute
end
def
geo_updated_event_source
is_wiki
?
Geo
::
RepositoryUpdatedEvent
::
WIKI
:
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
end
end
end
ee/app/services/ee/projects/update_service.rb
View file @
4c8fe525
...
...
@@ -63,7 +63,7 @@ module EE
end
def
sync_wiki_on_enable
::
Geo
::
RepositoryUpdatedService
.
new
(
project
,
source:
::
Geo
::
RepositoryUpdatedEvent
::
WIKI
).
execute
::
Geo
::
RepositoryUpdatedService
.
new
(
project
.
wiki
.
repository
).
execute
end
end
end
...
...
ee/app/services/ee/wiki_pages/base_service.rb
View file @
4c8fe525
...
...
@@ -16,7 +16,7 @@ module EE
def
process_wiki_repository_update
if
::
Gitlab
::
Geo
.
primary?
::
Geo
::
RepositoryUpdatedService
.
new
(
project
,
source:
::
Geo
::
RepositoryUpdatedEvent
::
WIKI
).
execute
::
Geo
::
RepositoryUpdatedService
.
new
(
project
.
wiki
.
repository
).
execute
end
end
end
...
...
ee/app/services/geo/repository_updated_service.rb
View file @
4c8fe525
...
...
@@ -4,12 +4,12 @@ module Geo
RepositoryUpdateError
=
Class
.
new
(
StandardError
)
def
initialize
(
project
,
params
=
{})
@project
=
project
def
initialize
(
repository
,
params
=
{})
@project
=
repository
.
project
@params
=
params
@refs
=
params
.
fetch
(
:refs
,
[])
@changes
=
params
.
fetch
(
:changes
,
[])
@source
=
params
.
fetch
(
:source
,
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
)
@source
=
repository
.
geo_updated_event_source
end
def
execute
...
...
ee/app/workers/ee/post_receive.rb
View file @
4c8fe525
...
...
@@ -12,7 +12,7 @@ module EE
super
if
::
Gitlab
::
Geo
.
primary?
::
Geo
::
RepositoryUpdatedService
.
new
(
post_received
.
project
,
refs:
refs
,
changes:
changes
).
execute
::
Geo
::
RepositoryUpdatedService
.
new
(
post_received
.
project
.
repository
,
refs:
refs
,
changes:
changes
).
execute
end
end
...
...
@@ -22,7 +22,7 @@ module EE
update_wiki_es_indexes
(
post_received
)
if
::
Gitlab
::
Geo
.
primary?
::
Geo
::
RepositoryUpdatedService
.
new
(
post_received
.
project
,
source:
::
Geo
::
RepositoryUpdatedEvent
::
WIKI
).
execute
::
Geo
::
RepositoryUpdatedService
.
new
(
post_received
.
project
.
wiki
.
repository
).
execute
end
end
...
...
ee/spec/models/project_spec.rb
View file @
4c8fe525
...
...
@@ -1649,12 +1649,12 @@ describe Project do
before
do
allow
(
::
Geo
::
RepositoryUpdatedService
)
.
to
receive
(
:new
)
.
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
)
.
with
(
project
.
repository
)
.
and_return
(
repository_updated_service
)
allow
(
::
Geo
::
RepositoryUpdatedService
)
.
to
receive
(
:new
)
.
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
.
with
(
project
.
wiki
.
repository
)
.
and_return
(
wiki_updated_service
)
end
...
...
ee/spec/services/geo/repository_updated_service_spec.rb
View file @
4c8fe525
...
...
@@ -13,7 +13,7 @@ describe Geo::RepositoryUpdatedService do
end
describe
'#execute'
do
subject
{
described_class
.
new
(
project
,
source:
source
)
}
subject
{
described_class
.
new
(
repository
)
}
shared_examples
'repository being updated'
do
context
'when not running on a primary node'
do
...
...
@@ -59,7 +59,7 @@ describe Geo::RepositoryUpdatedService do
end
it
'does not raise an error when project have never been verified'
do
expect
{
described_class
.
new
(
create
(
:project
))
}.
not_to
raise_error
expect
{
described_class
.
new
(
create
(
:project
)
.
repository
)
}.
not_to
raise_error
end
it
'raises a Geo::RepositoryUpdatedService::RepositoryUpdateError when an error occurs'
do
...
...
@@ -74,14 +74,14 @@ describe Geo::RepositoryUpdatedService do
context
'when repository is being updated'
do
include_examples
'repository being updated'
do
let
(
:
source
)
{
Geo
::
RepositoryUpdatedEvent
::
REPOSITORY
}
let
(
:
repository
)
{
project
.
repository
}
let
(
:method_prefix
)
{
'repository'
}
end
end
context
'when wiki is being updated'
do
include_examples
'repository being updated'
do
let
(
:
source
)
{
Geo
::
RepositoryUpdatedEvent
::
WIKI
}
let
(
:
repository
)
{
project
.
wiki
.
repository
}
let
(
:method_prefix
)
{
'wiki'
}
end
end
...
...
ee/spec/services/wiki_pages/create_service_spec.rb
View file @
4c8fe525
...
...
@@ -23,7 +23,7 @@ describe WikiPages::CreateService do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
repository_updated_service
=
instance_double
(
'::Geo::RepositoryUpdatedService'
)
expect
(
::
Geo
::
RepositoryUpdatedService
).
to
receive
(
:new
).
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
{
repository_updated_service
}
expect
(
::
Geo
::
RepositoryUpdatedService
).
to
receive
(
:new
).
with
(
project
.
wiki
.
repository
)
{
repository_updated_service
}
expect
(
repository_updated_service
).
to
receive
(
:execute
)
service
.
execute
...
...
@@ -32,7 +32,7 @@ describe WikiPages::CreateService do
it
'does not call Geo::RepositoryUpdatedService when not running on a Geo primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
(
::
Geo
::
RepositoryUpdatedService
).
not_to
receive
(
:new
).
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
expect
(
::
Geo
::
RepositoryUpdatedService
).
not_to
receive
(
:new
).
with
(
project
.
wiki
.
repository
)
service
.
execute
end
...
...
ee/spec/services/wiki_pages/destroy_service_spec.rb
View file @
4c8fe525
...
...
@@ -16,7 +16,7 @@ describe WikiPages::DestroyService do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
repository_updated_service
=
instance_double
(
'::Geo::RepositoryUpdatedService'
)
expect
(
::
Geo
::
RepositoryUpdatedService
).
to
receive
(
:new
).
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
{
repository_updated_service
}
expect
(
::
Geo
::
RepositoryUpdatedService
).
to
receive
(
:new
).
with
(
project
.
wiki
.
repository
)
{
repository_updated_service
}
expect
(
repository_updated_service
).
to
receive
(
:execute
)
service
.
execute
(
page
)
...
...
@@ -25,7 +25,7 @@ describe WikiPages::DestroyService do
it
'does not call Geo::RepositoryUpdatedService when not running on a Geo primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
(
::
Geo
::
RepositoryUpdatedService
).
not_to
receive
(
:new
).
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
expect
(
::
Geo
::
RepositoryUpdatedService
).
not_to
receive
(
:new
).
with
(
project
.
wiki
.
repository
)
service
.
execute
(
page
)
end
...
...
ee/spec/services/wiki_pages/update_service_spec.rb
View file @
4c8fe525
...
...
@@ -24,7 +24,7 @@ describe WikiPages::UpdateService do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
repository_updated_service
=
instance_double
(
'::Geo::RepositoryUpdatedService'
)
expect
(
::
Geo
::
RepositoryUpdatedService
).
to
receive
(
:new
).
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
{
repository_updated_service
}
expect
(
::
Geo
::
RepositoryUpdatedService
).
to
receive
(
:new
).
with
(
project
.
wiki
.
repository
)
{
repository_updated_service
}
expect
(
repository_updated_service
).
to
receive
(
:execute
)
service
.
execute
(
page
)
...
...
@@ -33,7 +33,7 @@ describe WikiPages::UpdateService do
it
'does not call Geo::RepositoryUpdatedService when not running on a Geo primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
(
::
Geo
::
RepositoryUpdatedService
).
not_to
receive
(
:new
).
with
(
project
,
source:
Geo
::
RepositoryUpdatedEvent
::
WIKI
)
expect
(
::
Geo
::
RepositoryUpdatedService
).
not_to
receive
(
:new
).
with
(
project
.
wiki
.
repository
)
service
.
execute
(
page
)
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