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
a5accabe
Commit
a5accabe
authored
Jul 16, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moves mirror updating logic over to project update service
parent
8c1215f3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
13 deletions
+21
-13
app/controllers/projects/mirrors_controller.rb
app/controllers/projects/mirrors_controller.rb
+3
-1
ee/app/controllers/ee/projects/mirrors_controller.rb
ee/app/controllers/ee/projects/mirrors_controller.rb
+11
-10
ee/app/services/ee/projects/update_service.rb
ee/app/services/ee/projects/update_service.rb
+4
-0
ee/spec/controllers/projects/mirrors_controller_spec.rb
ee/spec/controllers/projects/mirrors_controller_spec.rb
+0
-2
ee/spec/controllers/projects_controller_spec.rb
ee/spec/controllers/projects_controller_spec.rb
+2
-0
lib/api/projects.rb
lib/api/projects.rb
+1
-0
No files found.
app/controllers/projects/mirrors_controller.rb
View file @
a5accabe
...
...
@@ -15,7 +15,9 @@ class Projects::MirrorsController < Projects::ApplicationController
end
def
update
if
project
.
update
(
mirror_params
)
result
=
::
Projects
::
UpdateService
.
new
(
project
,
current_user
,
mirror_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
'Mirroring settings were successfully updated.'
else
flash
[
:alert
]
=
project
.
errors
.
full_messages
.
join
(
', '
).
html_safe
...
...
ee/app/controllers/ee/projects/mirrors_controller.rb
View file @
a5accabe
...
...
@@ -26,16 +26,17 @@ module EE
override
:update
def
update
if
project
.
update
(
safe_mirror_params
)
if
project
.
mirror?
project
.
force_import_job!
flash
[
:notice
]
=
"Mirroring settings were successfully updated. The project is being updated."
elsif
project
.
previous_changes
.
key?
(
'mirror'
)
flash
[
:notice
]
=
"Mirroring was successfully disabled."
else
flash
[
:notice
]
=
"Mirroring settings were successfully updated."
end
result
=
::
Projects
::
UpdateService
.
new
(
project
,
current_user
,
safe_mirror_params
).
execute
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
if
project
.
mirror?
"Mirroring settings were successfully updated. The project is being updated."
elsif
project
.
previous_changes
.
key?
(
'mirror'
)
"Mirroring was successfully disabled."
else
"Mirroring settings were successfully updated."
end
else
flash
[
:alert
]
=
project
.
errors
.
full_messages
.
join
(
', '
).
html_safe
end
...
...
ee/app/services/ee/projects/update_service.rb
View file @
a5accabe
...
...
@@ -11,6 +11,9 @@ module EE
params
.
delete
(
:mirror
)
params
.
delete
(
:mirror_user_id
)
params
.
delete
(
:mirror_trigger_builds
)
params
.
delete
(
:only_mirror_protected_branches
)
params
.
delete
(
:mirror_overwrites_diverged_branches
)
params
.
delete
(
:import_data_attributes
)
end
should_remove_old_approvers
=
params
.
delete
(
:remove_old_approvers
)
...
...
@@ -34,6 +37,7 @@ module EE
log_audit_events
sync_wiki_on_enable
if
!
wiki_was_enabled
&&
project
.
wiki_enabled?
project
.
force_import_job!
if
::
Gitlab
::
Utils
.
to_boolean
(
params
[
:mirror
])
&&
project
.
mirror?
end
result
...
...
ee/spec/controllers/projects/mirrors_controller_spec.rb
View file @
a5accabe
...
...
@@ -15,8 +15,6 @@ describe Projects::MirrorsController do
end
it
'allows to create a remote mirror'
do
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
expect
do
do_put
(
project
,
remote_mirrors_attributes:
{
'0'
=>
{
'enabled'
=>
1
,
'url'
=>
url
}
})
end
.
to
change
{
RemoteMirror
.
count
}.
to
(
1
)
...
...
ee/spec/controllers/projects_controller_spec.rb
View file @
a5accabe
...
...
@@ -144,6 +144,8 @@ describe ProjectsController do
end
it
'updates repository mirror attributes'
do
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
put
:update
,
namespace_id:
project
.
namespace
,
id:
project
,
...
...
lib/api/projects.rb
View file @
a5accabe
...
...
@@ -310,6 +310,7 @@ module API
authorize!
:change_visibility_level
,
user_project
if
attrs
[
:visibility
].
present?
attrs
=
translate_params_for_compatibility
(
attrs
)
attrs
[
:mirror
]
=
user_project
.
mirror?
unless
attrs
[
:mirror
].
present?
attrs
[
:mirror_user_id
]
=
current_user
.
id
unless
valid_mirror_user?
(
attrs
)
result
=
::
Projects
::
UpdateService
.
new
(
user_project
,
current_user
,
attrs
).
execute
...
...
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