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
80ea525a
Commit
80ea525a
authored
Mar 22, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename GitTagPushService -> Git::TagPushService
parent
e27f4c9c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
98 additions
and
94 deletions
+98
-94
app/services/git/tag_push_service.rb
app/services/git/tag_push_service.rb
+70
-0
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+0
-68
app/workers/post_receive.rb
app/workers/post_receive.rb
+1
-1
ee/app/services/ee/git/tag_push_service.rb
ee/app/services/ee/git/tag_push_service.rb
+16
-0
ee/app/services/ee/git_tag_push_service.rb
ee/app/services/ee/git_tag_push_service.rb
+0
-14
ee/app/services/projects/update_mirror_service.rb
ee/app/services/projects/update_mirror_service.rb
+1
-1
ee/spec/services/projects/update_mirror_service_spec.rb
ee/spec/services/projects/update_mirror_service_spec.rb
+2
-2
ee/spec/workers/post_receive_spec.rb
ee/spec/workers/post_receive_spec.rb
+1
-1
spec/services/git/tag_push_service_spec.rb
spec/services/git/tag_push_service_spec.rb
+1
-1
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+6
-6
No files found.
app/services/git/tag_push_service.rb
0 → 100644
View file @
80ea525a
# frozen_string_literal: true
module
Git
class
TagPushService
<
BaseService
attr_accessor
:push_data
def
execute
project
.
repository
.
after_create
if
project
.
empty_repo?
project
.
repository
.
before_push_tag
@push_data
=
build_push_data
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
push_data
).
execute
(
:push
,
pipeline_options
)
SystemHooksService
.
new
.
execute_hooks
(
build_system_push_data
,
:tag_push_hooks
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
push_data
.
dup
,
:tag_push_hooks
)
ProjectCacheWorker
.
perform_async
(
project
.
id
,
[],
[
:commit_count
,
:repository_size
])
true
end
private
def
build_push_data
commits
=
[]
message
=
nil
unless
Gitlab
::
Git
.
blank_ref?
(
params
[
:newrev
])
tag_name
=
Gitlab
::
Git
.
ref_name
(
params
[
:ref
])
tag
=
project
.
repository
.
find_tag
(
tag_name
)
if
tag
&&
tag
.
target
==
params
[
:newrev
]
commit
=
project
.
commit
(
tag
.
dereferenced_target
)
commits
=
[
commit
].
compact
message
=
tag
.
message
end
end
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
commits
,
message
,
push_options:
params
[
:push_options
]
||
[])
end
def
build_system_push_data
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
[],
''
)
end
def
pipeline_options
{}
# to be overridden in EE
end
end
end
Git
::
TagPushService
.
prepend
(
EE
::
Git
::
TagPushService
)
app/services/git_tag_push_service.rb
deleted
100644 → 0
View file @
e27f4c9c
# frozen_string_literal: true
class
GitTagPushService
<
BaseService
attr_accessor
:push_data
def
execute
project
.
repository
.
after_create
if
project
.
empty_repo?
project
.
repository
.
before_push_tag
@push_data
=
build_push_data
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
Ci
::
CreatePipelineService
.
new
(
project
,
current_user
,
push_data
).
execute
(
:push
,
pipeline_options
)
SystemHooksService
.
new
.
execute_hooks
(
build_system_push_data
,
:tag_push_hooks
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
push_data
.
dup
,
:tag_push_hooks
)
ProjectCacheWorker
.
perform_async
(
project
.
id
,
[],
[
:commit_count
,
:repository_size
])
true
end
private
def
build_push_data
commits
=
[]
message
=
nil
unless
Gitlab
::
Git
.
blank_ref?
(
params
[
:newrev
])
tag_name
=
Gitlab
::
Git
.
ref_name
(
params
[
:ref
])
tag
=
project
.
repository
.
find_tag
(
tag_name
)
if
tag
&&
tag
.
target
==
params
[
:newrev
]
commit
=
project
.
commit
(
tag
.
dereferenced_target
)
commits
=
[
commit
].
compact
message
=
tag
.
message
end
end
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
commits
,
message
,
push_options:
params
[
:push_options
]
||
[])
end
def
build_system_push_data
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
[],
''
)
end
def
pipeline_options
{}
# to be overridden in EE
end
end
GitTagPushService
.
prepend
(
EE
::
GitTagPushService
)
app/workers/post_receive.rb
View file @
80ea525a
...
...
@@ -38,7 +38,7 @@ class PostReceive
post_received
.
changes_refs
do
|
oldrev
,
newrev
,
ref
|
if
Gitlab
::
Git
.
tag_ref?
(
ref
)
GitTagPushService
.
new
(
Git
::
TagPushService
.
new
(
post_received
.
project
,
@user
,
oldrev:
oldrev
,
...
...
ee/app/services/ee/git/tag_push_service.rb
0 → 100644
View file @
80ea525a
# frozen_string_literal: true
module
EE
module
Git
module
TagPushService
extend
::
Gitlab
::
Utils
::
Override
private
override
:pipeline_options
def
pipeline_options
{
mirror_update:
params
[
:mirror_update
]
}
end
end
end
end
ee/app/services/ee/git_tag_push_service.rb
deleted
100644 → 0
View file @
e27f4c9c
# frozen_string_literal: true
module
EE
module
GitTagPushService
extend
::
Gitlab
::
Utils
::
Override
private
override
:pipeline_options
def
pipeline_options
{
mirror_update:
params
[
:mirror_update
]
}
end
end
end
ee/app/services/projects/update_mirror_service.rb
View file @
80ea525a
...
...
@@ -79,7 +79,7 @@ module Projects
next
if
old_tag_target
==
tag_target
GitTagPushService
.
new
(
Git
::
TagPushService
.
new
(
project
,
current_user
,
{
...
...
ee/spec/services/projects/update_mirror_service_spec.rb
View file @
80ea525a
...
...
@@ -59,10 +59,10 @@ describe Projects::UpdateMirrorService do
expect
(
project
.
repository
.
tag_names
).
to
include
(
'new-tag'
)
end
it
"only invokes GitTagPushService for tags pointing to commits"
do
it
"only invokes Git
::
TagPushService for tags pointing to commits"
do
stub_fetch_mirror
(
project
)
expect
(
GitTagPushService
).
to
receive
(
:new
)
expect
(
Git
::
TagPushService
).
to
receive
(
:new
)
.
with
(
project
,
project
.
owner
,
hash_including
(
ref:
'refs/tags/new-tag'
))
.
and_return
(
double
(
execute:
true
))
...
...
ee/spec/workers/post_receive_spec.rb
View file @
80ea525a
...
...
@@ -22,7 +22,7 @@ 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
(
GitTagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
allow_any_instance_of
(
Git
::
TagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
allow_any_instance_of
(
GitPushService
).
to
receive
(
:execute
).
and_return
(
true
)
end
...
...
spec/services/git
_
tag_push_service_spec.rb
→
spec/services/git
/
tag_push_service_spec.rb
View file @
80ea525a
require
'spec_helper'
describe
GitTagPushService
do
describe
Git
::
TagPushService
do
include
RepoHelpers
include
GitHelpers
...
...
spec/workers/post_receive_spec.rb
View file @
80ea525a
...
...
@@ -34,7 +34,7 @@ describe PostReceive do
context
'empty changes'
do
it
"does not call any PushService but runs after project hooks"
do
expect
(
GitPushService
).
not_to
receive
(
:new
)
expect
(
GitTagPushService
).
not_to
receive
(
:new
)
expect
(
Git
::
TagPushService
).
not_to
receive
(
:new
)
expect_next_instance_of
(
SystemHooksService
)
{
|
service
|
expect
(
service
).
to
receive
(
:execute_hooks
)
}
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
""
)
...
...
@@ -46,7 +46,7 @@ describe PostReceive do
it
'returns false'
do
expect
(
GitPushService
).
not_to
receive
(
:new
)
expect
(
GitTagPushService
).
not_to
receive
(
:new
)
expect
(
Git
::
TagPushService
).
not_to
receive
(
:new
)
expect
(
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)).
to
be
false
end
...
...
@@ -62,7 +62,7 @@ describe PostReceive do
it
"calls GitPushService"
do
expect_any_instance_of
(
GitPushService
).
to
receive
(
:execute
).
and_return
(
true
)
expect_any_instance_of
(
GitTagPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
Git
::
TagPushService
).
not_to
receive
(
:execute
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
end
end
...
...
@@ -70,9 +70,9 @@ describe PostReceive do
context
"tags"
do
let
(
:changes
)
{
"123456 789012 refs/tags/tag"
}
it
"calls GitTagPushService"
do
it
"calls Git
::
TagPushService"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
GitTagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
expect_any_instance_of
(
Git
::
TagPushService
).
to
receive
(
:execute
).
and_return
(
true
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
end
end
...
...
@@ -82,7 +82,7 @@ describe PostReceive do
it
"does not call any of the services"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
GitTagPushService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
Git
::
TagPushService
).
not_to
receive
(
:execute
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
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