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
c8066b36
Commit
c8066b36
authored
Mar 28, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE: Extract a Git::{Base,Tag,Branch}HooksService
parent
940e6cae
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
20 deletions
+52
-20
app/services/git/branch_hooks_service.rb
app/services/git/branch_hooks_service.rb
+2
-0
app/services/git/branch_push_service.rb
app/services/git/branch_push_service.rb
+1
-1
app/services/git/tag_hooks_service.rb
app/services/git/tag_hooks_service.rb
+2
-0
app/services/git/tag_push_service.rb
app/services/git/tag_push_service.rb
+0
-2
ee/app/services/ee/git/branch_hooks_service.rb
ee/app/services/ee/git/branch_hooks_service.rb
+19
-0
ee/app/services/ee/git/branch_push_service.rb
ee/app/services/ee/git/branch_push_service.rb
+19
-14
ee/app/services/ee/git/tag_hooks_service.rb
ee/app/services/ee/git/tag_hooks_service.rb
+1
-1
ee/spec/workers/post_receive_spec.rb
ee/spec/workers/post_receive_spec.rb
+8
-2
No files found.
app/services/git/branch_hooks_service.rb
View file @
c8066b36
...
...
@@ -142,3 +142,5 @@ module Git
end
end
end
Git
::
BranchHooksService
.
prepend
(
::
EE
::
Git
::
BranchHooksService
)
app/services/git/branch_push_service.rb
View file @
c8066b36
...
...
@@ -92,4 +92,4 @@ module Git
end
end
Git
::
BranchPushService
.
prepend
(
EE
::
Git
::
BranchPushService
)
Git
::
BranchPushService
.
prepend
(
::
EE
::
Git
::
BranchPushService
)
app/services/git/tag_hooks_service.rb
View file @
c8066b36
...
...
@@ -34,3 +34,5 @@ module Git
end
end
end
Git
::
TagHooksService
.
prepend
(
::
EE
::
Git
::
TagHooksService
)
app/services/git/tag_push_service.rb
View file @
c8066b36
...
...
@@ -12,5 +12,3 @@ module Git
end
end
end
Git
::
TagPushService
.
prepend
(
EE
::
Git
::
TagPushService
)
ee/app/services/ee/git/branch_hooks_service.rb
0 → 100644
View file @
c8066b36
# frozen_string_literal: true
module
EE
module
Git
module
BranchHooksService
extend
::
Gitlab
::
Utils
::
Override
private
override
:pipeline_options
def
pipeline_options
mirror_update
=
project
.
mirror?
&&
project
.
repository
.
up_to_date_with_upstream?
(
branch_name
)
{
mirror_update:
mirror_update
}
end
end
end
end
ee/app/services/ee/git/branch_push_service.rb
View file @
c8066b36
...
...
@@ -5,28 +5,33 @@ module EE
module
BranchPushService
extend
::
Gitlab
::
Utils
::
Override
protected
override
:execute_related_hooks
def
execute_related_hooks
if
should_index_commits?
::
ElasticCommitIndexerWorker
.
perform_async
(
project
.
id
,
params
[
:oldrev
],
params
[
:newrev
])
end
override
:execute
def
execute
enqueue_elasticsearch_indexing
super
end
private
def
should_index_commits?
default_branch?
&&
project
.
use_elasticsearch?
&&
::
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
!
redis
.
sismember
(
:elastic_projects_indexing
,
project
.
id
)
}
def
enqueue_elasticsearch_indexing
return
unless
should_index_commits?
::
ElasticCommitIndexerWorker
.
perform_async
(
project
.
id
,
params
[
:oldrev
],
params
[
:newrev
]
)
end
override
:pipeline_options
def
pipeline_options
{
mirror_update:
project
.
mirror?
&&
project
.
repository
.
up_to_date_with_upstream?
(
branch_name
)
}
def
should_index_commits?
return
false
unless
default_branch?
return
false
unless
project
.
use_elasticsearch?
# Check that we're not already indexing this project
::
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
!
redis
.
sismember
(
:elastic_projects_indexing
,
project
.
id
)
end
end
end
end
...
...
ee/app/services/ee/git/tag_
push
_service.rb
→
ee/app/services/ee/git/tag_
hooks
_service.rb
View file @
c8066b36
...
...
@@ -2,7 +2,7 @@
module
EE
module
Git
module
Tag
Push
Service
module
Tag
Hooks
Service
extend
::
Gitlab
::
Utils
::
Override
private
...
...
ee/spec/workers/post_receive_spec.rb
View file @
c8066b36
...
...
@@ -22,8 +22,14 @@ describe PostReceive do
allow_any_instance_of
(
Gitlab
::
DataBuilder
::
Repository
).
to
receive
(
:update
).
and_return
(
fake_hook_data
)
# silence hooks so we can isolate
allow_any_instance_of
(
Key
).
to
receive
(
:post_create_hook
).
and_return
(
true
)
allow_any_instance_of
(
Git
::
TagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
allow_any_instance_of
(
Git
::
BranchPushService
).
to
receive
(
:execute
).
and_return
(
true
)
expect_next_instance_of
(
Git
::
TagPushService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_return
(
true
)
end
expect_next_instance_of
(
Git
::
BranchPushService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_return
(
true
)
end
end
it
'calls Geo::RepositoryUpdatedService when running on a Geo primary node'
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