summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGabriel Mazetto <gabriel@gitlab.com>2016-04-15 08:08:22 -0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-04-19 11:00:30 +0200
commitee1090e2b2bc7b3762f6e2775f3fd15e92ae212b (patch)
tree9df863f27349ca2a95d0e6f16d99b85d4806d992 /lib
parent53a1d705fe536ad373faa77ba1ef5196ff49a98b (diff)
downloadgitlab-ce-ee1090e2b2bc7b3762f6e2775f3fd15e92ae212b.tar.gz
Added System Hooks for push and tag_push
Code is based on Project Webhooks, removing deprecations and without commits listing.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/push_data_builder.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb
index 97d1edab9c1..eb8e45040bc 100644
--- a/lib/gitlab/push_data_builder.rb
+++ b/lib/gitlab/push_data_builder.rb
@@ -36,7 +36,7 @@ module Gitlab
commit.hook_attrs(with_changed_files: true)
end
- type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push"
+ type = Gitlab::Git.tag_ref?(ref) ? 'tag_push' : 'push'
# Hash to be passed as post_receive_data
data = {
@@ -62,6 +62,26 @@ module Gitlab
data
end
+ def build_system(project, user, oldrev, newrev, ref)
+ type = Gitlab::Git.tag_ref?(ref) ? 'tag_push' : 'push'
+
+ data = {
+ event_name: type,
+ before: oldrev,
+ after: newrev,
+ ref: ref,
+ checkout_sha: checkout_sha(project.repository, newrev, ref),
+ user_id: user.id,
+ user_name: user.name,
+ user_email: user.email,
+ user_avatar: user.avatar_url,
+ project_id: project.id,
+ project: project.hook_attrs(backward: false)
+ }
+
+ data
+ end
+
# This method provide a sample data generated with
# existing project and commits to test webhooks
def build_sample(project, user)