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/app
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-12-04 17:23:21 +0300
committerValery Sizov <vsv2711@gmail.com>2015-12-04 17:23:21 +0300
commit5c1b49f494f07bf37ba3c60f3b9f70d1842d8b60 (patch)
tree309cb7f2725989f5cf52520688f484469081ed01 /app
parent4de7f32c60ea1f61768f9e8b18c3dca3edae9fdb (diff)
Add added, modified and removed properties to commit object in webhook
Diffstat (limited to 'app')
-rw-r--r--app/models/commit.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 492f6be1ce3..912b4dedf51 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -146,7 +146,10 @@ class Commit
author: {
name: author_name,
email: author_email
- }
+ },
+ added: repo_changes[:added],
+ modified: repo_changes[:modified],
+ removed: repo_changes[:removed]
}
end
@@ -196,4 +199,23 @@ class Commit
def status
ci_commit.try(:status) || :not_found
end
+
+ private
+
+ def repo_changes
+ changes = { added: [], modified: [], removed: [] }
+
+ 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
+
+ changes
+ end
end