Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-11-02 17:56:44 +0300
committerValery Sizov <vsv2711@gmail.com>2015-11-03 13:16:40 +0300
commit9479496f7584336788fc61121c096dfbcb3f6e4a (patch)
tree735eb8e0077c42629bf516b5498ff7e3ce5e4b2a /lib
parentb9e53258c505abeda8a975b550f2cb276caaf01b (diff)
Add added, modified and removed properties to commit object in webhook
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/push_data_builder.rb33
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