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 <vsv2711@gmail.com>2015-11-03 16:05:50 +0300
committerValery Sizov <vsv2711@gmail.com>2015-11-03 16:05:50 +0300
commitb12e17ff5574dd960550a7a4cdf92f22a6e67fb1 (patch)
treef699c23ed73e245855bbc026fd0d1d2e61f4e9ff /lib
parent86c0d8d28983c4f6abbcbf461e422b2fe5962847 (diff)
parent9479496f7584336788fc61121c096dfbcb3f6e4a (diff)
Merge branch 'web_hook_repo_changes'
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