summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-12-07 14:11:15 +0200
committerValery Sizov <vsv2711@gmail.com>2015-12-07 14:14:35 +0200
commit5df2c4419c5019b5003ddfa6adb59c84c3d9910c (patch)
tree12cdcec680fb9d97431ca14d9edd138aa7627f03 /app/models/commit.rb
parent5c1b49f494f07bf37ba3c60f3b9f70d1842d8b60 (diff)
downloadgitlab-ce-5df2c4419c5019b5003ddfa6adb59c84c3d9910c.tar.gz
fox specs
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb37
1 files changed, 23 insertions, 14 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 912b4dedf51..fecadfeec8e 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -135,10 +135,10 @@ class Commit
description.present?
end
- def hook_attrs
+ def hook_attrs(with_changed_files = false)
path_with_namespace = project.path_with_namespace
- {
+ data = {
id: id,
message: safe_message,
timestamp: committed_date.xmlschema,
@@ -146,11 +146,18 @@ class Commit
author: {
name: author_name,
email: author_email
- },
- added: repo_changes[:added],
- modified: repo_changes[:modified],
- removed: repo_changes[:removed]
+ }
}
+
+ if with_changed_files
+ data.merge!({
+ added: repo_changes[:added],
+ modified: repo_changes[:modified],
+ removed: repo_changes[:removed]
+ })
+ end
+
+ data
end
# Discover issues should be closed when this commit is pushed to a project's
@@ -205,14 +212,16 @@ class Commit
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
+ if diffs.any?
+ 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