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
f48605c7
Commit
f48605c7
authored
Dec 30, 2018
by
Jonathon Reinhart
Committed by
Gabriel Mazetto
Apr 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use all keyword args for DataBuilder::Push.build()
parent
8a07d5e6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
29 deletions
+38
-29
app/services/git/base_hooks_service.rb
app/services/git/base_hooks_service.rb
+7
-7
app/services/tags/destroy_service.rb
app/services/tags/destroy_service.rb
+5
-6
lib/gitlab/data_builder/push.rb
lib/gitlab/data_builder/push.rb
+10
-2
spec/lib/gitlab/data_builder/push_spec.rb
spec/lib/gitlab/data_builder/push_spec.rb
+7
-4
spec/models/project_services/hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+5
-6
spec/support/shared_examples/models/chat_service_spec.rb
spec/support/shared_examples/models/chat_service_spec.rb
+1
-1
spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb
...xamples/slack_mattermost_notifications_shared_examples.rb
+3
-3
No files found.
app/services/git/base_hooks_service.rb
View file @
f48605c7
...
...
@@ -73,13 +73,13 @@ module Git
def
push_data
@push_data
||=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
limited_commits
,
event_message
,
project
:
project
,
user:
current_user
,
oldrev:
params
[
:oldrev
],
newrev:
params
[
:newrev
],
ref:
params
[
:ref
],
commits:
limited_commits
,
message:
event_message
,
commits_count:
commits_count
,
push_options:
params
[
:push_options
]
||
{}
)
...
...
app/services/tags/destroy_service.rb
View file @
f48605c7
...
...
@@ -41,12 +41,11 @@ module Tags
def
build_push_data
(
tag
)
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
current_user
,
tag
.
dereferenced_target
.
sha
,
Gitlab
::
Git
::
BLANK_SHA
,
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
,
[])
project:
project
,
user:
current_user
,
oldrev:
tag
.
dereferenced_target
.
sha
,
newrev:
Gitlab
::
Git
::
BLANK_SHA
,
ref:
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
)
end
end
end
lib/gitlab/data_builder/push.rb
View file @
f48605c7
...
...
@@ -58,7 +58,10 @@ module Gitlab
# }
#
# rubocop:disable Metrics/ParameterLists
def
build
(
project
,
user
,
oldrev
,
newrev
,
ref
,
commits
=
[],
message
=
nil
,
commits_count:
nil
,
push_options:
{})
def
build
(
project
:,
user
:,
ref
:,
oldrev:
nil
,
newrev:
nil
,
commits:
[],
commits_count:
nil
,
message:
nil
,
push_options:
{})
commits
=
Array
(
commits
)
# Total commits count
...
...
@@ -113,7 +116,12 @@ module Gitlab
ref
=
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
project
.
default_branch
}
"
commits
=
project
.
repository
.
commits
(
project
.
default_branch
.
to_s
,
limit:
3
)
build
(
project
,
user
,
commits
.
last
&
.
id
,
commits
.
first
&
.
id
,
ref
,
commits
)
build
(
project:
project
,
user:
user
,
oldrev:
commits
.
last
&
.
id
,
newrev:
commits
.
first
&
.
id
,
ref:
ref
,
commits:
commits
)
end
def
sample_data
...
...
spec/lib/gitlab/data_builder/push_spec.rb
View file @
f48605c7
...
...
@@ -23,9 +23,12 @@ describe Gitlab::DataBuilder::Push do
describe
'.build'
do
let
(
:data
)
do
described_class
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
'8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b'
,
'refs/tags/v1.1.0'
)
described_class
.
build
(
project:
project
,
user:
user
,
oldrev:
Gitlab
::
Git
::
BLANK_SHA
,
newrev:
'8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b'
,
ref:
'refs/tags/v1.1.0'
)
end
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
...
...
@@ -47,7 +50,7 @@ describe Gitlab::DataBuilder::Push do
include_examples
'deprecated repository hook data'
it
'does not raise an error when given nil commits'
do
expect
{
described_class
.
build
(
spy
,
spy
,
spy
,
spy
,
'refs/tags/v1.1.0'
,
nil
)
}
expect
{
described_class
.
build
(
project:
spy
,
user:
spy
,
ref:
'refs/tags/v1.1.0'
,
commits:
nil
)
}
.
not_to
raise_error
end
end
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
f48605c7
...
...
@@ -98,12 +98,11 @@ describe HipchatService do
context
'tag_push events'
do
let
(
:push_sample_data
)
do
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
'1'
*
40
,
'refs/tags/test'
,
[])
project:
project
,
user:
user
,
oldrev:
Gitlab
::
Git
::
BLANK_SHA
,
newrev:
'1'
*
40
,
ref:
'refs/tags/test'
)
end
it
"calls Hipchat API for tag push events"
do
...
...
spec/support/shared_examples/models/chat_service_spec.rb
View file @
f48605c7
...
...
@@ -64,7 +64,7 @@ shared_examples_for "chat service" do |service_name|
context
"with not default branch"
do
let
(
:sample_data
)
do
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
user
,
nil
,
nil
,
"not-the-default-branch"
)
Gitlab
::
DataBuilder
::
Push
.
build
(
project
:
project
,
user:
user
,
ref:
"not-the-default-branch"
)
end
context
"when notify_only_default_branch enabled"
do
...
...
spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb
View file @
f48605c7
...
...
@@ -267,7 +267,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
it
'does not notify push events if they are not for the default branch'
do
ref
=
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}
test"
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
user
,
nil
,
nil
,
ref
,
[]
)
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
:
project
,
user:
user
,
ref:
ref
)
chat_service
.
execute
(
push_sample_data
)
...
...
@@ -284,7 +284,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
it
'still notifies about pushed tags'
do
ref
=
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}
test"
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
user
,
nil
,
nil
,
ref
,
[]
)
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
:
project
,
user:
user
,
ref:
ref
)
chat_service
.
execute
(
push_sample_data
)
...
...
@@ -299,7 +299,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
it
'notifies about all push events'
do
ref
=
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}
test"
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
,
user
,
nil
,
nil
,
ref
,
[]
)
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build
(
project
:
project
,
user:
user
,
ref:
ref
)
chat_service
.
execute
(
push_sample_data
)
...
...
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