diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-03 13:37:19 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-03 13:37:19 +0300 |
commit | 03b44916ba08ac766bb6763882be5704dca5b4ea (patch) | |
tree | 4decccab9407271d1971f28aee7b201a83637cc7 /app/models | |
parent | 1c077cac8a70ada8eda4a099d5bee92950eeda5d (diff) | |
parent | 1c9d2e39c1aef8e10ebff6e57c174c197a3a1c93 (diff) | |
download | gitlab-ce-03b44916ba08ac766bb6763882be5704dca5b4ea.tar.gz |
Merge pull request #7754 from Bugagazavr/hooks
More information in merge request hook
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit.rb | 15 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
-rw-r--r-- | app/models/issue.rb | 4 | ||||
-rw-r--r-- | app/models/merge_request.rb | 14 | ||||
-rw-r--r-- | app/models/project.rb | 10 |
5 files changed, 44 insertions, 1 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 7f586ebe781..a1343b65c72 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -88,6 +88,21 @@ class Commit description.present? end + def hook_attrs(project) + path_with_namespace = project.path_with_namespace + + { + id: id, + message: safe_message, + timestamp: committed_date.xmlschema, + url: "#{Gitlab.config.gitlab.url}/#{path_with_namespace}/commit/#{id}", + author: { + name: author_name, + email: author_email + } + } + end + # Discover issues should be closed when this commit is pushed to a project's # default branch. def closes_issues(project) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 698b5b8c30a..553087946d6 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -134,7 +134,7 @@ module Issuable def to_hook_data { object_kind: self.class.name.underscore, - object_attributes: self.attributes + object_attributes: hook_attrs } end diff --git a/app/models/issue.rb b/app/models/issue.rb index ed3d4445110..13152fdf94e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -48,6 +48,10 @@ class Issue < ActiveRecord::Base state :closed end + def hook_attrs + attributes + end + # Mentionable overrides. def gfm_reference diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 4894c617674..e0358c1889c 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -211,6 +211,20 @@ class MergeRequest < ActiveRecord::Base Gitlab::Satellite::MergeAction.new(current_user, self).format_patch end + def hook_attrs + attrs = { + source: source_project.hook_attrs, + target: target_project.hook_attrs, + last_commit: nil + } + + unless last_commit.nil? + attrs.merge!(last_commit: last_commit.hook_attrs(source_project)) + end + + attributes.merge!(attrs) + end + def for_fork? target_project != source_project end diff --git a/app/models/project.rb b/app/models/project.rb index 0e940bca2c9..d228da192e4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -544,6 +544,16 @@ class Project < ActiveRecord::Base end end + def hook_attrs + { + name: name, + ssh_url: ssh_url_to_repo, + http_url: http_url_to_repo, + namespace: namespace.name, + visibility_level: visibility_level + } + end + # Reset events cache related to this project # # Since we do cache @event we need to reset cache in special cases: |