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
487dfad6
Commit
487dfad6
authored
Jul 26, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix renaming repository when name contains invalid chars under settings
parent
ac7f3e6a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
3 deletions
+36
-3
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+11
-1
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+2
-0
app/views/projects/update.js.haml
app/views/projects/update.js.haml
+2
-2
spec/services/projects/update_service_spec.rb
spec/services/projects/update_service_spec.rb
+21
-0
No files found.
app/services/projects/update_service.rb
View file @
487dfad6
...
@@ -23,7 +23,17 @@ module Projects
...
@@ -23,7 +23,17 @@ module Projects
if
project
.
previous_changes
.
include?
(
'path'
)
if
project
.
previous_changes
.
include?
(
'path'
)
project
.
rename_repo
project
.
rename_repo
end
end
else
restore_attributes
false
end
end
end
end
private
def
restore_attributes
project
.
path
=
project
.
path_was
if
project
.
errors
.
include?
(
:path
)
project
.
name
=
project
.
name_was
if
project
.
errors
.
include?
(
:name
)
end
end
end
end
end
app/views/projects/edit.html.haml
View file @
487dfad6
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
%h4
.prepend-top-0
%h4
.prepend-top-0
Project settings
Project settings
.col-lg-9
.col-lg-9
.project-edit-errors
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
],
remote:
true
,
html:
{
multipart:
true
,
class:
"edit-project"
},
authenticity_token:
true
do
|
f
|
=
form_for
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
],
remote:
true
,
html:
{
multipart:
true
,
class:
"edit-project"
},
authenticity_token:
true
do
|
f
|
%fieldset
.append-bottom-0
%fieldset
.append-bottom-0
.form-group
.form-group
...
@@ -190,6 +191,7 @@
...
@@ -190,6 +191,7 @@
%h4
.prepend-top-0.warning-title
%h4
.prepend-top-0.warning-title
Rename repository
Rename repository
.col-lg-9
.col-lg-9
=
render
'projects/errors'
=
form_for
([
@project
.
namespace
.
becomes
(
Namespace
),
@project
])
do
|
f
|
=
form_for
([
@project
.
namespace
.
becomes
(
Namespace
),
@project
])
do
|
f
|
.form-group.project_name_holder
.form-group.project_name_holder
=
f
.
label
:name
,
class:
'label-light'
do
=
f
.
label
:name
,
class:
'label-light'
do
...
...
app/views/projects/update.js.haml
View file @
487dfad6
-
if
@project
.
valid
?
-
if
@project
.
errors
.
blank
?
:plain
:plain
location.href = "
#{
edit_namespace_project_path
(
@project
.
namespace
,
@project
)
}
";
location.href = "
#{
edit_namespace_project_path
(
@project
.
namespace
,
@project
)
}
";
-
else
-
else
...
@@ -6,4 +6,4 @@
...
@@ -6,4 +6,4 @@
$(".project-edit-errors").html("
#{
escape_javascript
(
render
(
'errors'
))
}
");
$(".project-edit-errors").html("
#{
escape_javascript
(
render
(
'errors'
))
}
");
$('.save-project-loader').hide();
$('.save-project-loader').hide();
$('.project-edit-container').show();
$('.project-edit-container').show();
$('.
project-edit-conten
t .btn-save').enable();
$('.
edit-projec
t .btn-save').enable();
spec/services/projects/update_service_spec.rb
View file @
487dfad6
...
@@ -139,6 +139,27 @@ describe Projects::UpdateService, services: true do
...
@@ -139,6 +139,27 @@ describe Projects::UpdateService, services: true do
end
end
end
end
context
'for invalid project path/name'
do
let
(
:user
)
{
create
(
:user
,
admin:
true
)
}
let
(
:project
)
{
create
(
:empty_project
,
path:
'gitlab'
,
name:
'sample'
)
}
let
(
:params
)
{
{
path:
'foo&bar'
,
name:
'foo&bar'
}
}
it
'resets to previous values to keep project in a valid state'
do
update_project
(
project
,
user
,
params
)
expect
(
project
.
path
).
to
eq
'gitlab'
expect
(
project
.
name
).
to
eq
'sample'
end
it
'keeps error messages'
do
update_project
(
project
,
user
,
params
)
expect
(
project
.
errors
).
not_to
be_blank
expect
(
project
.
errors
[
:name
]).
to
include
(
"can contain only letters, digits, '_', '.', dash and space. It must start with letter, digit or '_'."
)
expect
(
project
.
errors
[
:path
]).
to
include
(
"can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
)
end
end
def
update_project
(
project
,
user
,
opts
)
def
update_project
(
project
,
user
,
opts
)
Projects
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
Projects
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
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