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
558e9462
Commit
558e9462
authored
Mar 22, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename GitTagPushService -> Git::TagPushService
parent
ed99296e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
74 deletions
+76
-74
app/services/git/tag_push_service.rb
app/services/git/tag_push_service.rb
+68
-0
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+0
-66
app/workers/post_receive.rb
app/workers/post_receive.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 @
558e9462
# 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
app/services/git_tag_push_service.rb
deleted
100644 → 0
View file @
ed99296e
# 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
app/workers/post_receive.rb
View file @
558e9462
...
@@ -38,7 +38,7 @@ class PostReceive
...
@@ -38,7 +38,7 @@ class PostReceive
post_received
.
changes_refs
do
|
oldrev
,
newrev
,
ref
|
post_received
.
changes_refs
do
|
oldrev
,
newrev
,
ref
|
if
Gitlab
::
Git
.
tag_ref?
(
ref
)
if
Gitlab
::
Git
.
tag_ref?
(
ref
)
GitTagPushService
.
new
(
Git
::
TagPushService
.
new
(
post_received
.
project
,
post_received
.
project
,
@user
,
@user
,
oldrev:
oldrev
,
oldrev:
oldrev
,
...
...
spec/services/git
_
tag_push_service_spec.rb
→
spec/services/git
/
tag_push_service_spec.rb
View file @
558e9462
require
'spec_helper'
require
'spec_helper'
describe
GitTagPushService
do
describe
Git
::
TagPushService
do
include
RepoHelpers
include
RepoHelpers
include
GitHelpers
include
GitHelpers
...
...
spec/workers/post_receive_spec.rb
View file @
558e9462
...
@@ -34,7 +34,7 @@ describe PostReceive do
...
@@ -34,7 +34,7 @@ describe PostReceive do
context
'empty changes'
do
context
'empty changes'
do
it
"does not call any PushService but runs after project hooks"
do
it
"does not call any PushService but runs after project hooks"
do
expect
(
GitPushService
).
not_to
receive
(
:new
)
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
)
}
expect_next_instance_of
(
SystemHooksService
)
{
|
service
|
expect
(
service
).
to
receive
(
:execute_hooks
)
}
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
""
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
""
)
...
@@ -46,7 +46,7 @@ describe PostReceive do
...
@@ -46,7 +46,7 @@ describe PostReceive do
it
'returns false'
do
it
'returns false'
do
expect
(
GitPushService
).
not_to
receive
(
:new
)
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
expect
(
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)).
to
be
false
end
end
...
@@ -62,7 +62,7 @@ describe PostReceive do
...
@@ -62,7 +62,7 @@ describe PostReceive do
it
"calls GitPushService"
do
it
"calls GitPushService"
do
expect_any_instance_of
(
GitPushService
).
to
receive
(
:execute
).
and_return
(
true
)
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
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
end
end
end
end
...
@@ -70,9 +70,9 @@ describe PostReceive do
...
@@ -70,9 +70,9 @@ describe PostReceive do
context
"tags"
do
context
"tags"
do
let
(
:changes
)
{
"123456 789012 refs/tags/tag"
}
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
(
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
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
end
end
end
end
...
@@ -82,7 +82,7 @@ describe PostReceive do
...
@@ -82,7 +82,7 @@ describe PostReceive do
it
"does not call any of the services"
do
it
"does not call any of the services"
do
expect_any_instance_of
(
GitPushService
).
not_to
receive
(
:execute
)
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
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
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