diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2017-05-03 04:36:13 +0200 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2017-05-12 23:26:48 +0100 |
commit | f661980904f718440cc700b7d1f38ea8bf0e5480 (patch) | |
tree | 7933eee3b85e6af5da9db8223b6d870d8395926f /lib | |
parent | 8b17fb61b61b1f9707428c2333db2de29c4d3bcf (diff) | |
download | gitlab-ce-f661980904f718440cc700b7d1f38ea8bf0e5480.tar.gz |
Added repository_update hook
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/data_builder/repository.rb | 35 | ||||
-rw-r--r-- | lib/gitlab/git_post_receive.rb | 10 |
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/gitlab/data_builder/repository.rb b/lib/gitlab/data_builder/repository.rb new file mode 100644 index 00000000000..b42dc052949 --- /dev/null +++ b/lib/gitlab/data_builder/repository.rb @@ -0,0 +1,35 @@ +module Gitlab + module DataBuilder + module Repository + extend self + + # Produce a hash of post-receive data + def update(project, user, changes, refs) + { + event_name: 'repository_update', + + 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, + + changes: changes, + + refs: refs + } + end + + # Produce a hash of partial data for a single change + def single_change(oldrev, newrev, ref) + { + before: oldrev, + after: newrev, + ref: ref + } + end + end + end +end diff --git a/lib/gitlab/git_post_receive.rb b/lib/gitlab/git_post_receive.rb index 0e14253ab4e..742118b76a8 100644 --- a/lib/gitlab/git_post_receive.rb +++ b/lib/gitlab/git_post_receive.rb @@ -13,6 +13,16 @@ module Gitlab super(identifier, project, revision) end + def changes_refs + return enum_for(:changes_refs) unless block_given? + + changes.each do |change| + oldrev, newrev, ref = change.strip.split(' ') + + yield oldrev, newrev, ref + end + end + private def deserialize_changes(changes) |