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
a878fc9b
Commit
a878fc9b
authored
Feb 26, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug causing 'Import in progress' to be shown while a mirror is updating
parent
5626a5fb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
13 deletions
+92
-13
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-2
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+10
-4
ee/app/views/shared/_mirror_update_button.html.haml
ee/app/views/shared/_mirror_update_button.html.haml
+1
-1
ee/changelogs/unreleased/dm-project-updating-mirror.yml
ee/changelogs/unreleased/dm-project-updating-mirror.yml
+5
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+75
-6
No files found.
app/controllers/projects_controller.rb
View file @
a878fc9b
...
...
@@ -104,8 +104,7 @@ class ProjectsController < Projects::ApplicationController
end
def
show
# If we're importing while we do have a repository, we're simply updating the mirror.
if
@project
.
import_in_progress?
&&
!
@project
.
updating_mirror?
if
@project
.
import_in_progress?
redirect_to
project_import_path
(
@project
)
return
end
...
...
ee/app/models/ee/project.rb
View file @
a878fc9b
...
...
@@ -120,16 +120,22 @@ module EE
mirror?
&&
!
empty_repo?
end
def
scheduled_mirror?
override
:import_in_progress?
def
import_in_progress?
# If we're importing while we do have a repository, we're simply updating the mirror.
super
&&
!
mirror_with_content?
end
def
mirror_about_to_update?
return
false
unless
mirror_with_content?
return
false
if
mirror_hard_failed?
return
true
if
import_scheduled
?
return
false
if
updating_mirror
?
self
.
mirror_data
.
next_execution_timestamp
<=
Time
.
now
end
def
updating_mirror?
mirror_with_content?
&&
import_started
?
(
import_scheduled?
||
import_started?
)
&&
mirror_with_content
?
end
def
mirror_last_update_status
...
...
@@ -232,7 +238,7 @@ module EE
end
def
force_import_job!
return
if
scheduled_mirror
?
||
updating_mirror?
return
if
mirror_about_to_update
?
||
updating_mirror?
mirror_data
=
self
.
mirror_data
...
...
ee/app/views/shared/_mirror_update_button.html.haml
View file @
a878fc9b
-
if
@project
.
mirror?
&&
can?
(
current_user
,
:push_code
,
@project
)
.append-bottom-default
-
if
@project
.
scheduled_mirror
?
-
if
@project
.
mirror_about_to_update
?
%span
.btn.disabled
=
icon
(
"refresh spin"
)
Update Scheduled
…
...
...
ee/changelogs/unreleased/dm-project-updating-mirror.yml
0 → 100644
View file @
a878fc9b
---
title
:
Fix bug causing 'Import in progress' to be shown while a mirror is updating
merge_request
:
author
:
type
:
fixed
ee/spec/models/project_spec.rb
View file @
a878fc9b
...
...
@@ -349,7 +349,7 @@ describe Project do
end
end
describe
'#
scheduled_mirror
?'
do
describe
'#
mirror_about_to_update
?'
do
context
'when mirror is expected to run soon'
do
it
'returns true'
do
timestamp
=
Time
.
now
...
...
@@ -357,15 +357,15 @@ describe Project do
project
.
mirror_last_update_at
=
timestamp
-
3
.
minutes
project
.
mirror_data
.
next_execution_timestamp
=
timestamp
-
2
.
minutes
expect
(
project
.
scheduled_mirror
?
).
to
be
true
expect
(
project
.
mirror_about_to_update
?
).
to
be
true
end
end
context
'when mirror was scheduled'
do
it
'returns
tru
e'
do
it
'returns
fals
e'
do
project
=
create
(
:project
,
:mirror
,
:import_scheduled
,
:repository
)
expect
(
project
.
scheduled_mirror?
).
to
be
tru
e
expect
(
project
.
mirror_about_to_update?
).
to
be
fals
e
end
end
...
...
@@ -373,7 +373,68 @@ describe Project do
it
'returns false'
do
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
)
expect
(
project
.
scheduled_mirror?
).
to
be
false
expect
(
project
.
mirror_about_to_update?
).
to
be
false
end
end
end
describe
'#import_in_progress?'
do
let
(
:traits
)
{
[]
}
let
(
:project
)
{
create
(
:project
,
*
traits
,
import_url:
Project
::
UNKNOWN_IMPORT_URL
)
}
shared_examples
'import in progress'
do
context
'when project is a mirror'
do
before
do
traits
<<
:mirror
end
context
'when repository is empty'
do
it
'returns true'
do
expect
(
project
.
import_in_progress?
).
to
be_truthy
end
end
context
'when repository is not empty'
do
before
do
traits
<<
:repository
end
it
'returns false'
do
expect
(
project
.
import_in_progress?
).
to
be_falsey
end
end
end
context
'when project is not a mirror'
do
it
'returns true'
do
expect
(
project
.
import_in_progress?
).
to
be_truthy
end
end
end
context
'when import status is scheduled'
do
before
do
traits
<<
:import_scheduled
end
it_behaves_like
'import in progress'
end
context
'when import status is started'
do
before
do
traits
<<
:import_started
end
it_behaves_like
'import in progress'
end
context
'when import status is finished'
do
before
do
traits
<<
:import_finished
end
it
'returns false'
do
expect
(
project
.
import_in_progress?
).
to
be_falsey
end
end
end
...
...
@@ -395,13 +456,21 @@ describe Project do
end
end
context
'when mirror is
in progress
'
do
context
'when mirror is
started
'
do
it
'returns true'
do
project
=
create
(
:project
,
:mirror
,
:import_started
,
:repository
)
expect
(
project
.
updating_mirror?
).
to
be
true
end
end
context
'when mirror is scheduled'
do
it
'returns true'
do
project
=
create
(
:project
,
:mirror
,
:import_scheduled
,
:repository
)
expect
(
project
.
updating_mirror?
).
to
be
true
end
end
end
describe
'#mirror_last_update_status'
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