diff options
author | Zeger-Jan van de Weg <mail@zjvandeweg.nl> | 2015-11-11 13:07:02 +0100 |
---|---|---|
committer | Zeger-Jan van de Weg <mail@zjvandeweg.nl> | 2015-11-11 13:07:02 +0100 |
commit | 7e4a7d9ecc02db06c568a0de47e096edbdc1224b (patch) | |
tree | 701af1b1789f17950a22a19df4cf8f69d3beb173 /lib/gitlab/push_data_builder.rb | |
parent | 3f08e4b186bd02b37f34ccf1bc641a95f9d865ce (diff) | |
parent | dfa09789061bbd3891c17ebbcc23f7bd6b95336c (diff) | |
download | gitlab-ce-7e4a7d9ecc02db06c568a0de47e096edbdc1224b.tar.gz |
Merge branch 'master' into copying-file-seen-as-licence
Diffstat (limited to 'lib/gitlab/push_data_builder.rb')
-rw-r--r-- | lib/gitlab/push_data_builder.rb | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/gitlab/push_data_builder.rb b/lib/gitlab/push_data_builder.rb index d010ade704e..fa068d50763 100644 --- a/lib/gitlab/push_data_builder.rb +++ b/lib/gitlab/push_data_builder.rb @@ -18,7 +18,10 @@ module Gitlab # homepage: String, # }, # commits: Array, - # total_commits_count: Fixnum + # total_commits_count: Fixnum, + # added: ["CHANGELOG"], + # modified: [], + # removed: ["tmp/file.txt"] # } # def build(project, user, oldrev, newrev, ref, commits = [], message = nil) @@ -33,6 +36,8 @@ module Gitlab commit_attrs = commits_limited.map(&:hook_attrs) 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, @@ -55,7 +60,10 @@ module Gitlab visibility_level: project.visibility_level }, commits: commit_attrs, - total_commits_count: commits_count + total_commits_count: commits_count, + added: repo_changes[:added], + modified: repo_changes[:modified], + removed: repo_changes[:removed] } data @@ -86,6 +94,27 @@ 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 |