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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
5b0210a0
Commit
5b0210a0
authored
Jul 10, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ProcessCommitWorker when upstream project is deleted
parent
49d7f92f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
8 deletions
+42
-8
app/workers/process_commit_worker.rb
app/workers/process_commit_worker.rb
+3
-2
changelogs/unreleased/45592-nomethoderror-undefined-method-commit-for-nil-nilclass-in-sidekiq-caused-by-a-merge-commit-in-a-forked-project-with-upstream-project-deleted.yml
...mit-in-a-forked-project-with-upstream-project-deleted.yml
+5
-0
spec/workers/process_commit_worker_spec.rb
spec/workers/process_commit_worker_spec.rb
+34
-6
No files found.
app/workers/process_commit_worker.rb
View file @
5b0210a0
...
...
@@ -79,9 +79,10 @@ class ProcessCommitWorker
# 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
.
fork_source
return
false
unless
upstream_project
upstream_project
=
project
.
forked_from_project
commit_id
=
commit_hash
.
with_indifferent_access
[
:id
]
upstream_project
.
commit
(
commit_id
).
present?
end
...
...
changelogs/unreleased/45592-nomethoderror-undefined-method-commit-for-nil-nilclass-in-sidekiq-caused-by-a-merge-commit-in-a-forked-project-with-upstream-project-deleted.yml
0 → 100644
View file @
5b0210a0
---
title
:
Process commits as normal in forks when the upstream project is deleted
merge_request
:
20534
author
:
type
:
fixed
spec/workers/process_commit_worker_spec.rb
View file @
5b0210a0
require
'spec_helper'
describe
ProcessCommitWorker
do
include
ProjectForksHelper
let
(
:worker
)
{
described_class
.
new
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
...
...
@@ -32,15 +34,41 @@ 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
,
:repository
)
}
context
'when the project is forked'
do
context
'when commit already exists in the upstream project'
do
it
'does not process the commit message'
do
forked
=
fork_project
(
project
,
user
,
repository:
true
)
expect
(
worker
).
not_to
receive
(
:process_commit_message
)
worker
.
perform
(
forked
.
id
,
user
.
id
,
forked
.
commit
.
to_hash
)
end
end
context
'when the commit does not exist in the upstream project'
do
it
'processes the commit message'
do
empty_project
=
create
(
:project
,
:public
)
forked
=
fork_project
(
empty_project
,
user
,
repository:
true
)
TestEnv
.
copy_repo
(
forked
,
bare_repo:
TestEnv
.
factory_repo_path_bare
,
refs:
TestEnv
::
BRANCH_SHA
)
expect
(
worker
).
to
receive
(
:process_commit_message
)
worker
.
perform
(
forked
.
id
,
user
.
id
,
forked
.
commit
.
to_hash
)
end
end
it
'does not process commit message'
do
create
(
:forked_project_link
,
forked_to_project:
forked
,
forked_from_project:
project
)
context
'when the upstream project no longer exists'
do
it
'processes the commit message'
do
forked
=
fork_project
(
project
,
user
,
repository:
true
)
project
.
destroy!
expect
(
worker
).
not_
to
receive
(
:process_commit_message
)
expect
(
worker
).
to
receive
(
:process_commit_message
)
worker
.
perform
(
forked
.
id
,
user
.
id
,
forked
.
commit
.
to_hash
)
worker
.
perform
(
forked
.
id
,
user
.
id
,
forked
.
commit
.
to_hash
)
end
end
end
end
...
...
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