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:
authorFelipe Artur <felipefac@gmail.com>2017-05-18 23:17:58 +0300
committerFelipe Artur <felipefac@gmail.com>2017-05-22 23:43:27 +0300
commite44016b90ad900836b2cbc83ebb9f58c39b3576a (patch)
treec6d2b8f007846d557fd8dc2a408f984e69c0d416 /app/workers/process_commit_worker.rb
parent258f578fc8d58b3e343664ca59ab0df0d14057f0 (diff)
Prevent commits from upstream repositories to be re-processed by forks
Diffstat (limited to 'app/workers/process_commit_worker.rb')
-rw-r--r--app/workers/process_commit_worker.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb
index d6ed0e253ad..8b192aa74c6 100644
--- a/app/workers/process_commit_worker.rb
+++ b/app/workers/process_commit_worker.rb
@@ -17,6 +17,7 @@ class ProcessCommitWorker
project = Project.find_by(id: project_id)
return unless project
+ return if commit_exists_in_upstream?(project, commit_hash)
user = User.find_by(id: user_id)
@@ -76,4 +77,16 @@ class ProcessCommitWorker
Commit.from_hash(hash, project)
end
+
+ private
+
+ # Avoid to re-process commits messages that already exists in the upstream
+ # when project is forked. This will also prevent duplicated system notes.
+ def commit_exists_in_upstream?(project, commit_hash)
+ return false unless project.forked?
+
+ upstream_project = project.forked_from_project
+ commit_id = commit_hash.with_indifferent_access[:id]
+ upstream_project.commit(commit_id).present?
+ end
end