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
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-08 15:40:32 +0300
committerDouwe Maan <douwe@gitlab.com>2015-12-08 15:40:32 +0300
commit926c3bef9fbda49d5cab268bcd83355142e945c1 (patch)
tree1dc2b7eb13485f0fc656cc913ca56e57b672b62a /app/models/commit.rb
parent1a10945066d0da1801bb4cf89ce5f54996f1756f (diff)
parentf5430e48b42227f1c1874ca27c6907f0f704be28 (diff)
Merge branch 'master' into reference-pipeline-and-caching
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 7f9a6707966..ac22fc38ace 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -147,10 +147,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,
@@ -160,6 +160,12 @@ class Commit
email: author_email
}
}
+
+ if with_changed_files
+ data.merge!(repo_changes)
+ end
+
+ data
end
# Discover issues should be closed when this commit is pushed to a project's
@@ -208,4 +214,22 @@ class Commit
def status
ci_commit.try(:status) || :not_found
end
+
+ private
+
+ def repo_changes
+ changes = { added: [], modified: [], removed: [] }
+
+ diffs.each do |diff|
+ if diff.deleted_file
+ changes[:removed] << diff.old_path
+ elsif diff.renamed_file || diff.new_file
+ changes[:added] << diff.new_path
+ else
+ changes[:modified] << diff.new_path
+ end
+ end
+
+ changes
+ end
end