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>2017-05-25 21:59:35 +0300
committerDouwe Maan <douwe@gitlab.com>2017-05-25 21:59:35 +0300
commit67ea638921501296a2b1403fe039318bf7a61005 (patch)
tree8cfb57ecf777826197fb255a07b7adad9dd04eb7 /app/workers
parent3ba9702d74c1a89defbfad5fb8193023a3475c99 (diff)
parent005496354457cefba4f54e2d19f53888b2182727 (diff)
Merge branch 'issue_19262' into 'master'
Prevent commits from upstream repositories to be re-processed by forks Closes #19262 See merge request !11511
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/process_commit_worker.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb
index d6ed0e253ad..fe6a49976e0 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)
@@ -24,8 +25,6 @@ class ProcessCommitWorker
commit = build_commit(project, commit_hash)
- return unless commit.matches_cross_reference_regex?
-
author = commit.author || user
process_commit_message(project, commit, user, author, default)
@@ -76,4 +75,16 @@ class ProcessCommitWorker
Commit.from_hash(hash, project)
end
+
+ private
+
+ # Avoid reprocessing commits that already exist 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