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
ff83e599
Commit
ff83e599
authored
Aug 12, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
2c4ffdd3
d2ecbd74
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
53 additions
and
8 deletions
+53
-8
app/controllers/import/bitbucket_server_controller.rb
app/controllers/import/bitbucket_server_controller.rb
+7
-1
app/views/import/bitbucket_server/status.html.haml
app/views/import/bitbucket_server/status.html.haml
+8
-3
changelogs/unreleased/georgekoltsov-51260-add-filtering-to-bitbucket-server-import.yml
...oltsov-51260-add-filtering-to-bitbucket-server-import.yml
+5
-0
doc/user/project/import/bitbucket_server.md
doc/user/project/import/bitbucket_server.md
+4
-2
doc/user/project/import/img/bitbucket_server_import_select_project.png
...ect/import/img/bitbucket_server_import_select_project.png
+0
-0
doc/user/project/import/img/bitbucket_server_import_select_project_v12_3.png
...port/img/bitbucket_server_import_select_project_v12_3.png
+0
-0
lib/bitbucket_server/client.rb
lib/bitbucket_server/client.rb
+2
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/controllers/import/bitbucket_server_controller_spec.rb
spec/controllers/import/bitbucket_server_controller_spec.rb
+13
-1
spec/lib/bitbucket_server/client_spec.rb
spec/lib/bitbucket_server/client_spec.rb
+11
-0
No files found.
app/controllers/import/bitbucket_server_controller.rb
View file @
ff83e599
# frozen_string_literal: true
class
Import::BitbucketServerController
<
Import
::
BaseController
include
ActionView
::
Helpers
::
SanitizeHelper
before_action
:verify_bitbucket_server_import_enabled
before_action
:bitbucket_auth
,
except:
[
:new
,
:configure
]
before_action
:validate_import_params
,
only:
[
:create
]
...
...
@@ -57,7 +59,7 @@ class Import::BitbucketServerController < Import::BaseController
# rubocop: disable CodeReuse/ActiveRecord
def
status
@collection
=
bitbucket_client
.
repos
(
page_offset:
page_offset
,
limit:
limit_per_page
)
@collection
=
bitbucket_client
.
repos
(
page_offset:
page_offset
,
limit:
limit_per_page
,
filter:
sanitized_filter_param
)
@repos
,
@incompatible_repos
=
@collection
.
partition
{
|
repo
|
repo
.
valid?
}
# Use the import URL to filter beyond what BaseService#find_already_added_projects
...
...
@@ -147,4 +149,8 @@ class Import::BitbucketServerController < Import::BaseController
def
limit_per_page
BitbucketServer
::
Paginator
::
PAGE_LENGTH
end
def
sanitized_filter_param
sanitize
(
params
[
:filter
])
end
end
app/views/import/bitbucket_server/status.html.haml
View file @
ff83e599
...
...
@@ -17,8 +17,13 @@
=
button_tag
class:
'btn btn-import btn-success js-import-all'
do
=
_
(
'Import all projects'
)
=
icon
(
'spinner spin'
,
class:
'loading-icon'
)
.btn-group
=
link_to
(
'Reconfigure'
,
configure_import_bitbucket_server_path
,
class:
'btn btn-primary'
,
method: :post
)
.btn-group
=
link_to
(
'Reconfigure'
,
configure_import_bitbucket_server_path
,
class:
'btn btn-primary'
,
method: :post
)
.input-btn-group.float-right
=
form_tag
status_import_bitbucket_server_path
,
:method
=>
'get'
do
=
text_field_tag
:filter
,
sanitize
(
params
[
:filter
]),
class:
'form-control append-bottom-10'
,
placeholder:
_
(
'Filter your projects by name'
),
size:
40
,
autoFocus:
true
.table-responsive.prepend-top-10
%table
.table.import-jobs
...
...
@@ -62,7 +67,7 @@
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-group-text input-large form-control"
,
tabindex:
1
,
disabled:
true
%span
.input-group-prepend
.input-group-text
/
=
text_field_tag
:path
,
sanitize_project_name
(
repo
.
slug
),
class:
"input-mini form-control"
,
tabindex:
2
,
autofocus:
true
,
required:
true
=
text_field_tag
:path
,
sanitize_project_name
(
repo
.
slug
),
class:
"input-mini form-control"
,
tabindex:
2
,
required:
true
%td
.import-actions.job-status
=
button_tag
class:
'btn btn-import js-add-to-import'
do
Import
...
...
changelogs/unreleased/georgekoltsov-51260-add-filtering-to-bitbucket-server-import.yml
0 → 100644
View file @
ff83e599
---
title
:
Add BitBucketServer project import filtering
merge_request
:
31420
author
:
type
:
added
doc/user/project/import/bitbucket_server.md
View file @
ff83e599
...
...
@@ -32,6 +32,8 @@ Import your projects from Bitbucket Server to GitLab with minimal effort.
1.
Attachments in Markdown are currently not imported.
1.
Task lists are not imported.
1.
Emoji reactions are not imported
1.
Project filtering does not support fuzzy search (only
`starts with`
or
`full
match strings`
are currently supported)
## How it works
...
...
@@ -68,7 +70,7 @@ namespace that started the import process.
!
[
Grant access
](
img/bitbucket_server_import_credentials.png
)
1.
Click on the projects that you'd like to import or
**Import all projects**
.
You can also select the namespace under which each project will be
You can also
filter projects by name and
select the namespace under which each project will be
imported.
!
[
Import projects
](
img/bitbucket_server_import_select_project.png
)
!
[
Import projects
](
img/bitbucket_server_import_select_project
_v12_3
.png
)
doc/user/project/import/img/bitbucket_server_import_select_project.png
deleted
100644 → 0
View file @
2c4ffdd3
19 KB
doc/user/project/import/img/bitbucket_server_import_select_project_v12_3.png
0 → 100644
View file @
ff83e599
46 KB
lib/bitbucket_server/client.rb
View file @
ff83e599
...
...
@@ -23,8 +23,9 @@ module BitbucketServer
BitbucketServer
::
Representation
::
Repo
.
new
(
parsed_response
)
end
def
repos
(
page_offset:
0
,
limit:
nil
)
def
repos
(
page_offset:
0
,
limit:
nil
,
filter:
nil
)
path
=
"/repos"
path
+=
"?name=
#{
filter
}
"
if
filter
get_collection
(
path
,
:repo
,
page_offset:
page_offset
,
limit:
limit
)
end
...
...
locale/gitlab.pot
View file @
ff83e599
...
...
@@ -6343,6 +6343,9 @@ msgstr ""
msgid "Filter results by project"
msgstr ""
msgid "Filter your projects by name"
msgstr ""
msgid "Filter..."
msgstr ""
...
...
spec/controllers/import/bitbucket_server_controller_spec.rb
View file @
ff83e599
...
...
@@ -134,6 +134,8 @@ describe Import::BitbucketServerController do
describe
'GET status'
do
render_views
let
(
:repos
)
{
instance_double
(
BitbucketServer
::
Collection
)
}
before
do
allow
(
controller
).
to
receive
(
:bitbucket_client
).
and_return
(
client
)
...
...
@@ -145,7 +147,6 @@ describe Import::BitbucketServerController do
it
'assigns repository categories'
do
created_project
=
create
(
:project
,
:import_finished
,
import_type:
'bitbucket_server'
,
creator_id:
user
.
id
,
import_source:
@created_repo
.
browse_url
)
repos
=
instance_double
(
BitbucketServer
::
Collection
)
expect
(
repos
).
to
receive
(
:partition
).
and_return
([[
@repo
,
@created_repo
],
[
@invalid_repo
]])
expect
(
repos
).
to
receive
(
:current_page
).
and_return
(
1
)
...
...
@@ -159,6 +160,17 @@ describe Import::BitbucketServerController do
expect
(
assigns
(
:repos
)).
to
eq
([
@repo
])
expect
(
assigns
(
:incompatible_repos
)).
to
eq
([
@invalid_repo
])
end
context
'when filtering'
do
let
(
:filter
)
{
'test'
}
it
'passes filter param to bitbucket client'
do
expect
(
repos
).
to
receive
(
:partition
).
and_return
([[
@repo
,
@created_repo
],
[
@invalid_repo
]])
expect
(
client
).
to
receive
(
:repos
).
with
(
filter:
filter
,
limit:
25
,
page_offset:
0
).
and_return
(
repos
)
get
:status
,
params:
{
filter:
filter
},
as: :json
end
end
end
describe
'GET jobs'
do
...
...
spec/lib/bitbucket_server/client_spec.rb
View file @
ff83e599
...
...
@@ -58,6 +58,17 @@ describe BitbucketServer::Client do
subject
.
repos
(
page_offset:
10
,
limit:
25
)
end
context
'when filter param is passed'
do
let
(
:filter
)
{
'test'
}
let
(
:expected_path
)
{
"
#{
path
}
?name=
#{
filter
}
"
}
it
'requests a collection with filter applied'
do
expect
(
BitbucketServer
::
Paginator
).
to
receive
(
:new
).
with
(
anything
,
expected_path
,
:repo
,
page_offset:
0
,
limit:
nil
)
subject
.
repos
(
filter:
filter
)
end
end
end
describe
'#create_branch'
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