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
d9ff616f
Commit
d9ff616f
authored
Feb 20, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code style, directory structure.
parent
afe5d7d2
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
59 additions
and
57 deletions
+59
-57
app/models/project_services/asana_service.rb
app/models/project_services/asana_service.rb
+5
-5
app/models/project_services/campfire_service.rb
app/models/project_services/campfire_service.rb
+3
-3
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+3
-3
app/models/project_services/flowdock_service.rb
app/models/project_services/flowdock_service.rb
+5
-5
app/models/project_services/gemnasium_service.rb
app/models/project_services/gemnasium_service.rb
+5
-5
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+3
-3
app/models/project_services/pivotaltracker_service.rb
app/models/project_services/pivotaltracker_service.rb
+3
-3
app/models/project_services/pushover_service.rb
app/models/project_services/pushover_service.rb
+11
-11
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+13
-11
app/models/project_services/slack_service/slack_base_message.rb
...dels/project_services/slack_service/slack_base_message.rb
+2
-2
app/models/project_services/slack_service/slack_issue_message.rb
...els/project_services/slack_service/slack_issue_message.rb
+2
-2
app/models/project_services/slack_service/slack_merge_message.rb
...els/project_services/slack_service/slack_merge_message.rb
+2
-2
app/models/project_services/slack_service/slack_push_message.rb
...dels/project_services/slack_service/slack_push_message.rb
+2
-2
No files found.
app/models/project_services/asana_service.rb
View file @
d9ff616f
...
@@ -65,16 +65,16 @@ automatically inspected. Leave blank to include all branches.'
...
@@ -65,16 +65,16 @@ automatically inspected. Leave blank to include all branches.'
]
]
end
end
def
execute
(
push
)
def
execute
(
data
)
object_kind
=
push
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
Asana
.
configure
do
|
client
|
Asana
.
configure
do
|
client
|
client
.
api_key
=
api_key
client
.
api_key
=
api_key
end
end
user
=
push
[
:user_name
]
user
=
data
[
:user_name
]
branch
=
push
[
:ref
].
gsub
(
'refs/heads/'
,
''
)
branch
=
data
[
:ref
].
gsub
(
'refs/heads/'
,
''
)
branch_restriction
=
restrict_to_branch
.
to_s
branch_restriction
=
restrict_to_branch
.
to_s
...
@@ -86,7 +86,7 @@ automatically inspected. Leave blank to include all branches.'
...
@@ -86,7 +86,7 @@ automatically inspected. Leave blank to include all branches.'
project_name
=
project
.
name_with_namespace
project_name
=
project
.
name_with_namespace
push_msg
=
user
+
' pushed to branch '
+
branch
+
' of '
+
project_name
push_msg
=
user
+
' pushed to branch '
+
branch
+
' of '
+
project_name
push
[
:commits
].
each
do
|
commit
|
data
[
:commits
].
each
do
|
commit
|
check_commit
(
' ( '
+
commit
[
:url
]
+
' ): '
+
commit
[
:message
],
push_msg
)
check_commit
(
' ( '
+
commit
[
:url
]
+
' ): '
+
commit
[
:message
],
push_msg
)
end
end
end
end
...
...
app/models/project_services/campfire_service.rb
View file @
d9ff616f
...
@@ -41,14 +41,14 @@ class CampfireService < Service
...
@@ -41,14 +41,14 @@ class CampfireService < Service
]
]
end
end
def
execute
(
push_
data
)
def
execute
(
data
)
object_kind
=
push_
data
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
room
=
gate
.
find_room_by_name
(
self
.
room
)
room
=
gate
.
find_room_by_name
(
self
.
room
)
return
true
unless
room
return
true
unless
room
message
=
build_message
(
push_
data
)
message
=
build_message
(
data
)
room
.
speak
(
message
)
room
.
speak
(
message
)
end
end
...
...
app/models/project_services/emails_on_push_service.rb
View file @
d9ff616f
...
@@ -33,11 +33,11 @@ class EmailsOnPushService < Service
...
@@ -33,11 +33,11 @@ class EmailsOnPushService < Service
'emails_on_push'
'emails_on_push'
end
end
def
execute
(
push_
data
)
def
execute
(
data
)
object_kind
=
push_
data
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
push_
data
)
EmailsOnPushWorker
.
perform_async
(
project_id
,
recipients
,
data
)
end
end
def
fields
def
fields
...
...
app/models/project_services/flowdock_service.rb
View file @
d9ff616f
...
@@ -41,14 +41,14 @@ class FlowdockService < Service
...
@@ -41,14 +41,14 @@ class FlowdockService < Service
]
]
end
end
def
execute
(
push_
data
)
def
execute
(
data
)
object_kind
=
push_
data
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
Flowdock
::
Git
.
post
(
Flowdock
::
Git
.
post
(
push_
data
[
:ref
],
data
[
:ref
],
push_
data
[
:before
],
data
[
:before
],
push_
data
[
:after
],
data
[
:after
],
token:
token
,
token:
token
,
repo:
project
.
repository
.
path_to_repo
,
repo:
project
.
repository
.
path_to_repo
,
repo_url:
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
path_with_namespace
}
"
,
repo_url:
"
#{
Gitlab
.
config
.
gitlab
.
url
}
/
#{
project
.
path_with_namespace
}
"
,
...
...
app/models/project_services/gemnasium_service.rb
View file @
d9ff616f
...
@@ -42,14 +42,14 @@ class GemnasiumService < Service
...
@@ -42,14 +42,14 @@ class GemnasiumService < Service
]
]
end
end
def
execute
(
push_
data
)
def
execute
(
data
)
object_kind
=
push_
data
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
Gemnasium
::
GitlabService
.
execute
(
Gemnasium
::
GitlabService
.
execute
(
ref:
push_
data
[
:ref
],
ref:
data
[
:ref
],
before:
push_
data
[
:before
],
before:
data
[
:before
],
after:
push_
data
[
:after
],
after:
data
[
:after
],
token:
token
,
token:
token
,
api_key:
api_key
,
api_key:
api_key
,
repo:
project
.
repository
.
path_to_repo
repo:
project
.
repository
.
path_to_repo
...
...
app/models/project_services/hipchat_service.rb
View file @
d9ff616f
...
@@ -44,11 +44,11 @@ class HipchatService < Service
...
@@ -44,11 +44,11 @@ class HipchatService < Service
]
]
end
end
def
execute
(
push_
data
)
def
execute
(
data
)
object_kind
=
push_data
.
fetch
(
:object_kind
)
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
gate
[
room
].
send
(
'GitLab'
,
create_message
(
push_
data
))
gate
[
room
].
send
(
'GitLab'
,
create_message
(
data
))
end
end
private
private
...
...
app/models/project_services/pivotaltracker_service.rb
View file @
d9ff616f
...
@@ -41,12 +41,12 @@ class PivotaltrackerService < Service
...
@@ -41,12 +41,12 @@ class PivotaltrackerService < Service
]
]
end
end
def
execute
(
push
)
def
execute
(
data
)
object_kind
=
push
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
url
=
'https://www.pivotaltracker.com/services/v5/source_commits'
url
=
'https://www.pivotaltracker.com/services/v5/source_commits'
push
[
:commits
].
each
do
|
commit
|
data
[
:commits
].
each
do
|
commit
|
message
=
{
message
=
{
'source_commit'
=>
{
'source_commit'
=>
{
'commit_id'
=>
commit
[
:id
],
'commit_id'
=>
commit
[
:id
],
...
...
app/models/project_services/pushover_service.rb
View file @
d9ff616f
...
@@ -80,24 +80,24 @@ class PushoverService < Service
...
@@ -80,24 +80,24 @@ class PushoverService < Service
]
]
end
end
def
execute
(
push_
data
)
def
execute
(
data
)
object_kind
=
push_
data
[
:object_kind
]
object_kind
=
data
[
:object_kind
]
return
unless
object_kind
==
"push"
return
unless
object_kind
==
"push"
ref
=
push_
data
[
:ref
].
gsub
(
'refs/heads/'
,
''
)
ref
=
data
[
:ref
].
gsub
(
'refs/heads/'
,
''
)
before
=
push_
data
[
:before
]
before
=
data
[
:before
]
after
=
push_
data
[
:after
]
after
=
data
[
:after
]
if
before
.
include?
(
'000000'
)
if
before
.
include?
(
'000000'
)
message
=
"
#{
push_
data
[
:user_name
]
}
pushed new branch
\"
#{
ref
}
\"
."
message
=
"
#{
data
[
:user_name
]
}
pushed new branch
\"
#{
ref
}
\"
."
elsif
after
.
include?
(
'000000'
)
elsif
after
.
include?
(
'000000'
)
message
=
"
#{
push_
data
[
:user_name
]
}
deleted branch
\"
#{
ref
}
\"
."
message
=
"
#{
data
[
:user_name
]
}
deleted branch
\"
#{
ref
}
\"
."
else
else
message
=
"
#{
push_
data
[
:user_name
]
}
push to branch
\"
#{
ref
}
\"
."
message
=
"
#{
data
[
:user_name
]
}
push to branch
\"
#{
ref
}
\"
."
end
end
if
push_
data
[
:total_commits_count
]
>
0
if
data
[
:total_commits_count
]
>
0
message
<<
"
\n
Total commits count:
#{
push_
data
[
:total_commits_count
]
}
"
message
<<
"
\n
Total commits count:
#{
data
[
:total_commits_count
]
}
"
end
end
pushover_data
=
{
pushover_data
=
{
...
@@ -107,7 +107,7 @@ class PushoverService < Service
...
@@ -107,7 +107,7 @@ class PushoverService < Service
priority:
priority
,
priority:
priority
,
title:
"
#{
project
.
name_with_namespace
}
"
,
title:
"
#{
project
.
name_with_namespace
}
"
,
message:
message
,
message:
message
,
url:
push_
data
[
:repository
][
:homepage
],
url:
data
[
:repository
][
:homepage
],
url_title:
"See project
#{
project
.
name_with_namespace
}
"
url_title:
"See project
#{
project
.
name_with_namespace
}
"
}
}
...
...
app/models/project_services/slack_service.rb
View file @
d9ff616f
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
# merge_requests_events :boolean default(TRUE)
# merge_requests_events :boolean default(TRUE)
# tag_push_events :boolean default(TRUE)
# tag_push_events :boolean default(TRUE)
#
#
require
"slack_messages/slack_issue_message"
require
"slack_messages/slack_push_message"
require
"slack_messages/slack_merge_message"
class
SlackService
<
Service
class
SlackService
<
Service
prop_accessor
:webhook
,
:username
,
:channel
prop_accessor
:webhook
,
:username
,
:channel
...
@@ -59,13 +56,14 @@ class SlackService < Service
...
@@ -59,13 +56,14 @@ class SlackService < Service
# 'close' action. Ignore update events for now to prevent duplicate
# 'close' action. Ignore update events for now to prevent duplicate
# messages from arriving.
# messages from arriving.
message
=
case
object_kind
message
=
\
case
object_kind
when
"push"
when
"push"
message
=
SlackMessages
::
Slack
PushMessage
.
new
(
data
)
PushMessage
.
new
(
data
)
when
"issue"
when
"issue"
message
=
SlackMessages
::
Slack
IssueMessage
.
new
(
data
)
unless
is_update?
(
data
)
IssueMessage
.
new
(
data
)
unless
is_update?
(
data
)
when
"merge_request"
when
"merge_request"
message
=
SlackMessages
::
Slack
MergeMessage
.
new
(
data
)
unless
is_update?
(
data
)
MergeMessage
.
new
(
data
)
unless
is_update?
(
data
)
end
end
opt
=
{}
opt
=
{}
...
@@ -92,3 +90,7 @@ class SlackService < Service
...
@@ -92,3 +90,7 @@ class SlackService < Service
data
[
:object_attributes
][
:action
]
==
'update'
data
[
:object_attributes
][
:action
]
==
'update'
end
end
end
end
require
"slack_service/issue_message"
require
"slack_service/push_message"
require
"slack_service/merge_message"
\ No newline at end of file
app/models/project_services/slack_
messages
/slack_base_message.rb
→
app/models/project_services/slack_
service
/slack_base_message.rb
View file @
d9ff616f
require
'slack-notifier'
require
'slack-notifier'
module
SlackMessages
class
SlackService
class
Slack
BaseMessage
class
BaseMessage
def
initialize
(
params
)
def
initialize
(
params
)
raise
NotImplementedError
raise
NotImplementedError
end
end
...
...
app/models/project_services/slack_
messages
/slack_issue_message.rb
→
app/models/project_services/slack_
service
/slack_issue_message.rb
View file @
d9ff616f
module
Slack
Messages
module
Slack
Service
class
SlackIssueMessage
<
Slack
BaseMessage
class
IssueMessage
<
BaseMessage
attr_reader
:username
attr_reader
:username
attr_reader
:title
attr_reader
:title
attr_reader
:project_name
attr_reader
:project_name
...
...
app/models/project_services/slack_
messages
/slack_merge_message.rb
→
app/models/project_services/slack_
service
/slack_merge_message.rb
View file @
d9ff616f
module
Slack
Messages
module
Slack
Service
class
SlackMergeMessage
<
Slack
BaseMessage
class
MergeMessage
<
BaseMessage
attr_reader
:username
attr_reader
:username
attr_reader
:project_name
attr_reader
:project_name
attr_reader
:project_url
attr_reader
:project_url
...
...
app/models/project_services/slack_
messages
/slack_push_message.rb
→
app/models/project_services/slack_
service
/slack_push_message.rb
View file @
d9ff616f
require
'slack-notifier'
require
'slack-notifier'
module
Slack
Messages
module
Slack
Service
class
SlackPushMessage
<
Slack
BaseMessage
class
PushMessage
<
BaseMessage
attr_reader
:after
attr_reader
:after
attr_reader
:before
attr_reader
:before
attr_reader
:commits
attr_reader
:commits
...
...
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