BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
984367f9
Commit
984367f9
authored
Aug 04, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move those builders to their own namespace, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5620#note_13540099
parent
80671bf7
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
79 additions
and
44 deletions
+79
-44
build.rb
app/models/ci/build.rb
+2
-2
builds_email_service.rb
app/models/project_services/builds_email_service.rb
+1
-1
service.rb
app/models/service.rb
+1
-1
delete_branch_service.rb
app/services/delete_branch_service.rb
+1
-1
delete_tag_service.rb
app/services/delete_tag_service.rb
+1
-1
git_push_service.rb
app/services/git_push_service.rb
+2
-2
git_tag_push_service.rb
app/services/git_tag_push_service.rb
+2
-2
post_process_service.rb
app/services/notes/post_process_service.rb
+1
-1
test_hook_service.rb
app/services/test_hook_service.rb
+2
-1
build_data_builder.rb
lib/gitlab/data_builder/build_data_builder.rb
+4
-2
note_data_builder.rb
lib/gitlab/data_builder/note_data_builder.rb
+4
-2
push_data_builder.rb
lib/gitlab/data_builder/push_data_builder.rb
+4
-2
build_data_builder_spec.rb
spec/lib/gitlab/data_builder/build_data_builder_spec.rb
+2
-2
note_data_builder_spec.rb
spec/lib/gitlab/data_builder/note_data_builder_spec.rb
+2
-2
push_data_builder_spec.rb
spec/lib/gitlab/data_builder/push_data_builder_spec.rb
+1
-1
assembla_service_spec.rb
spec/models/project_services/assembla_service_spec.rb
+2
-1
builds_email_service_spec.rb
spec/models/project_services/builds_email_service_spec.rb
+5
-3
drone_ci_service_spec.rb
spec/models/project_services/drone_ci_service_spec.rb
+3
-1
flowdock_service_spec.rb
spec/models/project_services/flowdock_service_spec.rb
+2
-1
gemnasium_service_spec.rb
spec/models/project_services/gemnasium_service_spec.rb
+2
-1
hipchat_service_spec.rb
spec/models/project_services/hipchat_service_spec.rb
+17
-7
irker_service_spec.rb
spec/models/project_services/irker_service_spec.rb
+3
-1
jira_service_spec.rb
spec/models/project_services/jira_service_spec.rb
+2
-1
pushover_service_spec.rb
spec/models/project_services/pushover_service_spec.rb
+3
-1
slack_service_spec.rb
spec/models/project_services/slack_service_spec.rb
+3
-1
user_spec.rb
spec/models/user_spec.rb
+3
-1
build_email_worker_spec.rb
spec/workers/build_email_worker_spec.rb
+1
-1
emails_on_push_worker_spec.rb
spec/workers/emails_on_push_worker_spec.rb
+3
-1
No files found.
app/models/ci/build.rb
View file @
984367f9
...
...
@@ -349,7 +349,7 @@ module Ci
def
execute_hooks
return
unless
project
build_data
=
Gitlab
::
BuildDataBuilder
.
build
(
self
)
build_data
=
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
self
)
project
.
execute_hooks
(
build_data
.
dup
,
:build_hooks
)
project
.
execute_services
(
build_data
.
dup
,
:build_hooks
)
project
.
running_or_pending_build_count
(
force:
true
)
...
...
@@ -461,7 +461,7 @@ module Ci
def
build_attributes_from_config
return
{}
unless
pipeline
.
config_processor
pipeline
.
config_processor
.
build_attributes
(
name
)
end
end
...
...
app/models/project_services/builds_email_service.rb
View file @
984367f9
...
...
@@ -52,7 +52,7 @@ class BuildsEmailService < Service
def
test_data
(
project
=
nil
,
user
=
nil
)
build
=
project
.
builds
.
last
Gitlab
::
BuildDataBuilder
.
build
(
build
)
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
build
)
end
def
fields
...
...
app/models/service.rb
View file @
984367f9
...
...
@@ -80,7 +80,7 @@ class Service < ActiveRecord::Base
end
def
test_data
(
project
,
user
)
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
def
event_channel_names
...
...
app/services/delete_branch_service.rb
View file @
984367f9
...
...
@@ -39,7 +39,7 @@ class DeleteBranchService < BaseService
end
def
build_push_data
(
branch
)
Gitlab
::
PushDataBuilder
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
project
,
current_user
,
branch
.
target
.
sha
,
Gitlab
::
Git
::
BLANK_SHA
,
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
branch
.
name
}
"
,
[])
end
end
app/services/delete_tag_service.rb
View file @
984367f9
...
...
@@ -33,7 +33,7 @@ class DeleteTagService < BaseService
end
def
build_push_data
(
tag
)
Gitlab
::
PushDataBuilder
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
project
,
current_user
,
tag
.
target
.
sha
,
Gitlab
::
Git
::
BLANK_SHA
,
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
,
[])
end
end
app/services/git_push_service.rb
View file @
984367f9
...
...
@@ -138,12 +138,12 @@ class GitPushService < BaseService
end
def
build_push_data
@push_data
||=
Gitlab
::
PushDataBuilder
.
@push_data
||=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
@project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
push_commits
)
end
def
build_push_data_system_hook
@push_data_system
||=
Gitlab
::
PushDataBuilder
.
@push_data_system
||=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
@project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
[])
end
...
...
app/services/git_tag_push_service.rb
View file @
984367f9
...
...
@@ -34,12 +34,12 @@ class GitTagPushService < BaseService
end
end
Gitlab
::
PushDataBuilder
.
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
commits
,
message
)
end
def
build_system_push_data
Gitlab
::
PushDataBuilder
.
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
project
,
current_user
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
],
[],
''
)
end
end
app/services/notes/post_process_service.rb
View file @
984367f9
...
...
@@ -16,7 +16,7 @@ module Notes
end
def
hook_data
Gitlab
::
NoteDataBuilder
.
build
(
@note
,
@note
.
author
)
Gitlab
::
DataBuilder
::
NoteDataBuilder
.
build
(
@note
,
@note
.
author
)
end
def
execute_note_hooks
...
...
app/services/test_hook_service.rb
View file @
984367f9
class
TestHookService
def
execute
(
hook
,
current_user
)
data
=
Gitlab
::
PushDataBuilder
.
build_sample
(
hook
.
project
,
current_user
)
data
=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
hook
.
project
,
current_user
)
hook
.
execute
(
data
,
'push_hooks'
)
end
end
lib/gitlab/build_data_builder.rb
→
lib/gitlab/
data_builder/
build_data_builder.rb
View file @
984367f9
module
Gitlab
class
BuildDataBuilder
class
<<
self
module
DataBuilder
module
BuildDataBuilder
module_function
def
build
(
build
)
project
=
build
.
project
commit
=
build
.
pipeline
...
...
lib/gitlab/note_data_builder.rb
→
lib/gitlab/
data_builder/
note_data_builder.rb
View file @
984367f9
module
Gitlab
class
NoteDataBuilder
class
<<
self
module
DataBuilder
module
NoteDataBuilder
module_function
# Produce a hash of post-receive data
#
# For all notes:
...
...
lib/gitlab/push_data_builder.rb
→
lib/gitlab/
data_builder/
push_data_builder.rb
View file @
984367f9
module
Gitlab
class
PushDataBuilder
class
<<
self
module
DataBuilder
module
PushDataBuilder
module_function
# Produce a hash of post-receive data
#
# data = {
...
...
spec/lib/gitlab/build_data_builder_spec.rb
→
spec/lib/gitlab/
data_builder/
build_data_builder_spec.rb
View file @
984367f9
require
'spec_helper'
describe
'Gitlab::BuildDataBuilder'
do
describe
Gitlab
::
DataBuilder
::
BuildDataBuilder
do
let
(
:build
)
{
create
(
:ci_build
)
}
describe
'.build'
do
let
(
:data
)
do
Gitlab
::
BuildDataBuilder
.
build
(
build
)
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
build
)
end
it
{
expect
(
data
).
to
be_a
(
Hash
)
}
...
...
spec/lib/gitlab/note_data_builder_spec.rb
→
spec/lib/gitlab/
data_builder/
note_data_builder_spec.rb
View file @
984367f9
require
'spec_helper'
describe
'Gitlab::NoteDataBuilder'
,
lib:
true
do
describe
Gitlab
::
DataBuilder
::
NoteDataBuilder
,
lib:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:data
)
{
Gitlab
::
NoteDataBuilder
.
build
(
note
,
user
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
NoteDataBuilder
.
build
(
note
,
user
)
}
let
(
:fixed_time
)
{
Time
.
at
(
1425600000
)
}
# Avoid time precision errors
before
(
:each
)
do
...
...
spec/lib/gitlab/push_data_builder_spec.rb
→
spec/lib/gitlab/
data_builder/
push_data_builder_spec.rb
View file @
984367f9
require
'spec_helper'
describe
Gitlab
::
PushDataBuilder
,
lib:
true
do
describe
Gitlab
::
DataBuilder
::
PushDataBuilder
,
lib:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/models/project_services/assembla_service_spec.rb
View file @
984367f9
...
...
@@ -39,7 +39,8 @@ describe AssemblaService, models: true do
token:
'verySecret'
,
subdomain:
'project_name'
)
@sample_data
=
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
@sample_data
=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
@api_url
=
'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret'
WebMock
.
stub_request
(
:post
,
@api_url
)
end
...
...
spec/models/project_services/builds_email_service_spec.rb
View file @
984367f9
require
'spec_helper'
describe
BuildsEmailService
do
let
(
:data
)
{
Gitlab
::
BuildDataBuilder
.
build
(
create
(
:ci_build
))
}
let
(
:data
)
do
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
create
(
:ci_build
))
end
describe
'Validations'
do
context
'when service is active'
do
...
...
@@ -39,7 +41,7 @@ describe BuildsEmailService do
describe
'#test'
do
it
'sends email'
do
data
=
Gitlab
::
BuildDataBuilder
.
build
(
create
(
:ci_build
))
data
=
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
create
(
:ci_build
))
subject
.
recipients
=
'test@gitlab.com'
expect
(
BuildEmailWorker
).
to
receive
(
:perform_async
)
...
...
@@ -49,7 +51,7 @@ describe BuildsEmailService do
context
'notify only failed builds is true'
do
it
'sends email'
do
data
=
Gitlab
::
BuildDataBuilder
.
build
(
create
(
:ci_build
))
data
=
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
create
(
:ci_build
))
data
[
:build_status
]
=
"success"
subject
.
recipients
=
'test@gitlab.com'
...
...
spec/models/project_services/drone_ci_service_spec.rb
View file @
984367f9
...
...
@@ -84,7 +84,9 @@ describe DroneCiService, models: true do
include_context
:drone_ci_service
let
(
:user
)
{
create
(
:user
,
username:
'username'
)
}
let
(
:push_sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:push_sample_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
it
do
service_hook
=
double
...
...
spec/models/project_services/flowdock_service_spec.rb
View file @
984367f9
...
...
@@ -52,7 +52,8 @@ describe FlowdockService, models: true do
service_hook:
true
,
token:
'verySecret'
)
@sample_data
=
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
@sample_data
=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
@api_url
=
'https://api.flowdock.com/v1/messages'
WebMock
.
stub_request
(
:post
,
@api_url
)
end
...
...
spec/models/project_services/gemnasium_service_spec.rb
View file @
984367f9
...
...
@@ -55,7 +55,8 @@ describe GemnasiumService, models: true do
token:
'verySecret'
,
api_key:
'GemnasiumUserApiKey'
)
@sample_data
=
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
@sample_data
=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
it
"should call Gemnasium service"
do
expect
(
Gemnasium
::
GitlabService
).
to
receive
(
:execute
).
with
(
an_instance_of
(
Hash
)).
once
...
...
spec/models/project_services/hipchat_service_spec.rb
View file @
984367f9
...
...
@@ -48,7 +48,9 @@ describe HipchatService, models: true do
let
(
:project_name
)
{
project
.
name_with_namespace
.
gsub
(
/\s/
,
''
)
}
let
(
:token
)
{
'verySecret'
}
let
(
:server_url
)
{
'https://hipchat.example.com'
}
let
(
:push_sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:push_sample_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
before
(
:each
)
do
allow
(
hipchat
).
to
receive_messages
(
...
...
@@ -108,7 +110,15 @@ describe HipchatService, models: true do
end
context
'tag_push events'
do
let
(
:push_sample_data
)
{
Gitlab
::
PushDataBuilder
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
'1'
*
40
,
'refs/tags/test'
,
[])
}
let
(
:push_sample_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
'1'
*
40
,
'refs/tags/test'
,
[])
end
it
"should call Hipchat API for tag push events"
do
hipchat
.
execute
(
push_sample_data
)
...
...
@@ -185,7 +195,7 @@ describe HipchatService, models: true do
end
it
"should call Hipchat API for commit comment events"
do
data
=
Gitlab
::
NoteDataBuilder
.
build
(
commit_note
,
user
)
data
=
Gitlab
::
DataBuilder
::
NoteDataBuilder
.
build
(
commit_note
,
user
)
hipchat
.
execute
(
data
)
expect
(
WebMock
).
to
have_requested
(
:post
,
api_url
).
once
...
...
@@ -217,7 +227,7 @@ describe HipchatService, models: true do
end
it
"should call Hipchat API for merge request comment events"
do
data
=
Gitlab
::
NoteDataBuilder
.
build
(
merge_request_note
,
user
)
data
=
Gitlab
::
DataBuilder
::
NoteDataBuilder
.
build
(
merge_request_note
,
user
)
hipchat
.
execute
(
data
)
expect
(
WebMock
).
to
have_requested
(
:post
,
api_url
).
once
...
...
@@ -244,7 +254,7 @@ describe HipchatService, models: true do
end
it
"should call Hipchat API for issue comment events"
do
data
=
Gitlab
::
NoteDataBuilder
.
build
(
issue_note
,
user
)
data
=
Gitlab
::
DataBuilder
::
NoteDataBuilder
.
build
(
issue_note
,
user
)
hipchat
.
execute
(
data
)
message
=
hipchat
.
send
(
:create_message
,
data
)
...
...
@@ -270,7 +280,7 @@ describe HipchatService, models: true do
end
it
"should call Hipchat API for snippet comment events"
do
data
=
Gitlab
::
NoteDataBuilder
.
build
(
snippet_note
,
user
)
data
=
Gitlab
::
DataBuilder
::
NoteDataBuilder
.
build
(
snippet_note
,
user
)
hipchat
.
execute
(
data
)
expect
(
WebMock
).
to
have_requested
(
:post
,
api_url
).
once
...
...
@@ -292,7 +302,7 @@ describe HipchatService, models: true do
context
'build events'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:data
)
{
Gitlab
::
BuildDataBuilder
.
build
(
build
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
build
)
}
context
'for failed'
do
before
{
build
.
drop
}
...
...
spec/models/project_services/irker_service_spec.rb
View file @
984367f9
...
...
@@ -46,7 +46,9 @@ describe IrkerService, models: true do
let
(
:irker
)
{
IrkerService
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:sample_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
let
(
:recipients
)
{
'#commits irc://test.net/#test ftp://bad'
}
let
(
:colorize_messages
)
{
'1'
}
...
...
spec/models/project_services/jira_service_spec.rb
View file @
984367f9
...
...
@@ -66,7 +66,8 @@ describe JiraService, models: true do
password:
'gitlab_jira_password'
)
@jira_service
.
save
# will build API URL, as api_url was not specified above
@sample_data
=
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
@sample_data
=
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
# https://github.com/bblimke/webmock#request-with-basic-authentication
@api_url
=
'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/transitions'
@comment_url
=
'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/comment'
...
...
spec/models/project_services/pushover_service_spec.rb
View file @
984367f9
...
...
@@ -48,7 +48,9 @@ describe PushoverService, models: true do
let
(
:pushover
)
{
PushoverService
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:sample_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
let
(
:api_key
)
{
'verySecret'
}
let
(
:user_key
)
{
'verySecret'
}
...
...
spec/models/project_services/slack_service_spec.rb
View file @
984367f9
...
...
@@ -45,7 +45,9 @@ describe SlackService, models: true do
let
(
:slack
)
{
SlackService
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:push_sample_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:push_sample_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
let
(
:webhook_url
)
{
'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685'
}
let
(
:username
)
{
'slack_username'
}
let
(
:channel
)
{
'slack_channel'
}
...
...
spec/models/user_spec.rb
View file @
984367f9
...
...
@@ -895,7 +895,9 @@ describe User, models: true do
subject
{
create
(
:user
)
}
let!
(
:project1
)
{
create
(
:project
)
}
let!
(
:project2
)
{
create
(
:project
,
forked_from_project:
project1
)
}
let!
(
:push_data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project2
,
subject
)
}
let!
(
:push_data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project2
,
subject
)
end
let!
(
:push_event
)
{
create
(
:event
,
action:
Event
::
PUSHED
,
project:
project2
,
target:
project1
,
author:
subject
,
data:
push_data
)
}
before
do
...
...
spec/workers/build_email_worker_spec.rb
View file @
984367f9
...
...
@@ -5,7 +5,7 @@ describe BuildEmailWorker do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:data
)
{
Gitlab
::
BuildDataBuilder
.
build
(
build
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
BuildDataBuilder
.
build
(
build
)
}
subject
{
BuildEmailWorker
.
new
}
...
...
spec/workers/emails_on_push_worker_spec.rb
View file @
984367f9
...
...
@@ -5,7 +5,9 @@ describe EmailsOnPushWorker do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:data
)
{
Gitlab
::
PushDataBuilder
.
build_sample
(
project
,
user
)
}
let
(
:data
)
do
Gitlab
::
DataBuilder
::
PushDataBuilder
.
build_sample
(
project
,
user
)
end
let
(
:recipients
)
{
user
.
email
}
let
(
:perform
)
{
subject
.
perform
(
project
.
id
,
recipients
,
data
.
stringify_keys
)
}
...
...
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