Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e44016b9
Commit
e44016b9
authored
May 18, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent commits from upstream repositories to be re-processed by forks
parent
258f578f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
app/workers/process_commit_worker.rb
app/workers/process_commit_worker.rb
+13
-0
changelogs/unreleased/issue_19262.yml
changelogs/unreleased/issue_19262.yml
+4
-0
spec/workers/process_commit_worker_spec.rb
spec/workers/process_commit_worker_spec.rb
+12
-0
No files found.
app/workers/process_commit_worker.rb
View file @
e44016b9
...
...
@@ -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
changelogs/unreleased/issue_19262.yml
0 → 100644
View file @
e44016b9
---
title
:
Prevent commits from upstream repositories to be re-processed by forks
merge_request
:
author
:
spec/workers/process_commit_worker_spec.rb
View file @
e44016b9
...
...
@@ -39,6 +39,18 @@ describe ProcessCommitWorker do
worker
.
perform
(
project
.
id
,
user
.
id
,
commit
.
to_hash
)
end
context
'when commit already exists in upstream project'
do
let
(
:forked
)
{
create
(
:project
,
:public
)
}
it
'does not process commit message'
do
create
(
:forked_project_link
,
forked_to_project:
forked
,
forked_from_project:
project
)
expect
(
worker
).
not_to
receive
(
:process_commit_message
)
worker
.
perform
(
forked
.
id
,
user
.
id
,
forked
.
commit
.
to_hash
)
end
end
end
describe
'#process_commit_message'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment