diff options
author | Valery Sizov <valery@gitlab.com> | 2015-12-07 14:43:13 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-12-07 14:43:13 +0000 |
commit | bd5fb1b479f29df3c2150b6c375c1b7bffd28931 (patch) | |
tree | 6786dc0077d83a639753723a1ae1fadb0dfba257 /lib | |
parent | e88fd58671f5407d80fafe1070d48b750b9f2e50 (diff) | |
parent | 3c97cbc74cf87856ed7b1af197358d4e3adb1240 (diff) | |
download | gitlab-ce-bd5fb1b479f29df3c2150b6c375c1b7bffd28931.tar.gz |
Merge branch 'webhook_payload_with_changes' into 'master'
Add added, modified and removed properties to commit object in webhook
https://gitlab.com/gitlab-org/gitlab-ee/issues/20
See merge request !1988
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/push_data_builder.rb | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb index fa068d50763..4f9cdef3869 100644 --- a/lib/gitlab/push_data_builder.rb +++ b/lib/gitlab/push_data_builder.rb @@ -18,10 +18,7 @@ module Gitlab # homepage: String, # }, # commits: Array, - # total_commits_count: Fixnum, - # added: ["CHANGELOG"], - # modified: [], - # removed: ["tmp/file.txt"] + # total_commits_count: Fixnum # } # def build(project, user, oldrev, newrev, ref, commits = [], message = nil) @@ -33,11 +30,12 @@ module Gitlab # For performance purposes maximum 20 latest commits # will be passed as post receive hook data. - commit_attrs = commits_limited.map(&:hook_attrs) + commit_attrs = commits_limited.map do |commit| + commit.hook_attrs(with_changed_files: true) + end type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push" - repo_changes = repo_changes(project, newrev, oldrev) # Hash to be passed as post_receive_data data = { object_kind: type, @@ -60,10 +58,7 @@ module Gitlab visibility_level: project.visibility_level }, commits: commit_attrs, - total_commits_count: commits_count, - added: repo_changes[:added], - modified: repo_changes[:modified], - removed: repo_changes[:removed] + total_commits_count: commits_count } data @@ -94,27 +89,6 @@ module Gitlab newrev end end - - def repo_changes(project, newrev, oldrev) - changes = { added: [], modified: [], removed: [] } - compare_result = CompareService.new. - execute(project, newrev, project, oldrev) - - if compare_result - compare_result.diffs.each do |diff| - case true - when diff.deleted_file - changes[:removed] << diff.old_path - when diff.renamed_file, diff.new_file - changes[:added] << diff.new_path - else - changes[:modified] << diff.new_path - end - end - end - - changes - end end end end |