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
1486304d
Commit
1486304d
authored
Jan 30, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
4fd4c9b2
95e220de
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
113 additions
and
61 deletions
+113
-61
.gitlab/issue_templates/Coding style proposal.md
.gitlab/issue_templates/Coding style proposal.md
+0
-0
app/controllers/import/bitbucket_server_controller.rb
app/controllers/import/bitbucket_server_controller.rb
+5
-2
app/helpers/import_helper.rb
app/helpers/import_helper.rb
+3
-1
app/views/import/bitbucket_server/status.html.haml
app/views/import/bitbucket_server/status.html.haml
+1
-1
changelogs/unreleased/sh-issue-53419-fix.yml
changelogs/unreleased/sh-issue-53419-fix.yml
+5
-0
doc/install/installation.md
doc/install/installation.md
+76
-54
spec/controllers/import/bitbucket_server_controller_spec.rb
spec/controllers/import/bitbucket_server_controller_spec.rb
+19
-3
spec/helpers/import_helper_spec.rb
spec/helpers/import_helper_spec.rb
+4
-0
No files found.
.gitlab/issue_templates/
Add
style proposal.md
→
.gitlab/issue_templates/
Coding
style proposal.md
View file @
1486304d
File moved
app/controllers/import/bitbucket_server_controller.rb
View file @
1486304d
...
...
@@ -13,7 +13,10 @@ class Import::BitbucketServerController < Import::BaseController
# Repository names are limited to 128 characters. They must start with a
# letter or number and may contain spaces, hyphens, underscores, and periods.
# (https://community.atlassian.com/t5/Answers-Developer-Questions/stash-repository-names/qaq-p/499054)
VALID_BITBUCKET_CHARS
=
/\A[\w\-_\.\s]+\z/
#
# Bitbucket Server starts personal project names with a tilde.
VALID_BITBUCKET_PROJECT_CHARS
=
/\A~?[\w\-\.\s]+\z/
VALID_BITBUCKET_CHARS
=
/\A[\w\-\.\s]+\z/
def
new
end
...
...
@@ -91,7 +94,7 @@ class Import::BitbucketServerController < Import::BaseController
return
render_validation_error
(
'Missing project key'
)
unless
@project_key
.
present?
&&
@repo_slug
.
present?
return
render_validation_error
(
'Missing repository slug'
)
unless
@repo_slug
.
present?
return
render_validation_error
(
'Invalid project key'
)
unless
@project_key
=~
VALID_BITBUCKET_CHARS
return
render_validation_error
(
'Invalid project key'
)
unless
@project_key
=~
VALID_BITBUCKET_
PROJECT_
CHARS
return
render_validation_error
(
'Invalid repository slug'
)
unless
@repo_slug
=~
VALID_BITBUCKET_CHARS
end
...
...
app/helpers/import_helper.rb
View file @
1486304d
...
...
@@ -8,7 +8,9 @@ module ImportHelper
end
def
sanitize_project_name
(
name
)
name
.
gsub
(
/[^\w\-]/
,
'-'
)
# For personal projects in Bitbucket in the form ~username, we can
# just drop that leading tilde.
name
.
gsub
(
/\A~+/
,
''
).
gsub
(
/[^\w\-]/
,
'-'
)
end
def
import_project_target
(
owner
,
name
)
...
...
app/views/import/bitbucket_server/status.html.haml
View file @
1486304d
...
...
@@ -56,7 +56,7 @@
.project-path.input-group-prepend
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:extra_group
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
project_key
,
path:
repo
.
project_key
)
}
:
{}
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
sanitize_project_name
(
repo
.
project_key
),
path:
sanitize_project_name
(
repo
.
project_key
)
)
}
:
{}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'input-group-text select2 js-select-namespace'
,
tabindex:
1
}
-
else
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-group-text input-large form-control"
,
tabindex:
1
,
disabled:
true
...
...
changelogs/unreleased/sh-issue-53419-fix.yml
0 → 100644
View file @
1486304d
---
title
:
Fix Bitbucket Server import not allowing personal projects
merge_request
:
23601
author
:
type
:
fixed
doc/install/installation.md
View file @
1486304d
This diff is collapsed.
Click to expand it.
spec/controllers/import/bitbucket_server_controller_spec.rb
View file @
1486304d
...
...
@@ -28,9 +28,11 @@ describe Import::BitbucketServerController do
end
describe
'POST create'
do
let
(
:project_name
)
{
"my-project_123"
}
before
do
allow
(
controller
).
to
receive
(
:bitbucket_client
).
and_return
(
client
)
repo
=
double
(
name:
'my-project'
)
repo
=
double
(
name:
project_name
)
allow
(
client
).
to
receive
(
:repo
).
with
(
project_key
,
repo_slug
).
and_return
(
repo
)
assign_session_tokens
end
...
...
@@ -39,7 +41,7 @@ describe Import::BitbucketServerController do
it
'returns the new project'
do
allow
(
Gitlab
::
BitbucketServerImport
::
ProjectCreator
)
.
to
receive
(
:new
).
with
(
project_key
,
repo_slug
,
anything
,
'my-project'
,
user
.
namespace
,
user
,
anything
)
.
to
receive
(
:new
).
with
(
project_key
,
repo_slug
,
anything
,
project_name
,
user
.
namespace
,
user
,
anything
)
.
and_return
(
double
(
execute:
project
))
post
:create
,
params:
{
project:
project_key
,
repository:
repo_slug
},
format: :json
...
...
@@ -47,6 +49,20 @@ describe Import::BitbucketServerController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
context
'with project key with tildes'
do
let
(
:project_key
)
{
'~someuser_123'
}
it
'successfully creates a project'
do
allow
(
Gitlab
::
BitbucketServerImport
::
ProjectCreator
)
.
to
receive
(
:new
).
with
(
project_key
,
repo_slug
,
anything
,
project_name
,
user
.
namespace
,
user
,
anything
)
.
and_return
(
double
(
execute:
project
))
post
:create
,
params:
{
project:
project_key
,
repository:
repo_slug
,
format: :json
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
it
'returns an error when an invalid project key is used'
do
post
:create
,
params:
{
project:
'some&project'
}
...
...
@@ -69,7 +85,7 @@ describe Import::BitbucketServerController do
it
'returns an error when the project cannot be saved'
do
allow
(
Gitlab
::
BitbucketServerImport
::
ProjectCreator
)
.
to
receive
(
:new
).
with
(
project_key
,
repo_slug
,
anything
,
'my-project'
,
user
.
namespace
,
user
,
anything
)
.
to
receive
(
:new
).
with
(
project_key
,
repo_slug
,
anything
,
project_name
,
user
.
namespace
,
user
,
anything
)
.
and_return
(
double
(
execute:
build
(
:project
)))
post
:create
,
params:
{
project:
project_key
,
repository:
repo_slug
},
format: :json
...
...
spec/helpers/import_helper_spec.rb
View file @
1486304d
...
...
@@ -2,6 +2,10 @@ require 'rails_helper'
describe
ImportHelper
do
describe
'#sanitize_project_name'
do
it
'removes leading tildes'
do
expect
(
helper
.
sanitize_project_name
(
'~~root'
)).
to
eq
(
'root'
)
end
it
'removes whitespace'
do
expect
(
helper
.
sanitize_project_name
(
'my test repo'
)).
to
eq
(
'my-test-repo'
)
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