Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7e5524bc
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7e5524bc
编写于
8月 29, 2019
作者:
G
George Koltsov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add project filtering to Bitbucket Cloud import
上级
edd04207
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
44 addition
and
8 deletion
+44
-8
app/controllers/import/bitbucket_controller.rb
app/controllers/import/bitbucket_controller.rb
+7
-1
app/views/import/bitbucket/status.html.haml
app/views/import/bitbucket/status.html.haml
+10
-2
app/views/import/bitbucket_server/status.html.haml
app/views/import/bitbucket_server/status.html.haml
+1
-1
changelogs/unreleased/georgekoltsov-bitbucket-cloud-import-filtering.yml
...leased/georgekoltsov-bitbucket-cloud-import-filtering.yml
+5
-0
doc/user/project/import/bitbucket.md
doc/user/project/import/bitbucket.md
+3
-3
doc/user/project/import/img/bitbucket_import_select_project.png
...er/project/import/img/bitbucket_import_select_project.png
+0
-0
doc/user/project/import/img/bitbucket_import_select_project_v12_3.png
...ject/import/img/bitbucket_import_select_project_v12_3.png
+0
-0
lib/bitbucket/client.rb
lib/bitbucket/client.rb
+3
-1
spec/controllers/import/bitbucket_controller_spec.rb
spec/controllers/import/bitbucket_controller_spec.rb
+15
-0
未找到文件。
app/controllers/import/bitbucket_controller.rb
浏览文件 @
7e5524bc
# frozen_string_literal: true
# frozen_string_literal: true
class
Import::BitbucketController
<
Import
::
BaseController
class
Import::BitbucketController
<
Import
::
BaseController
include
ActionView
::
Helpers
::
SanitizeHelper
before_action
:verify_bitbucket_import_enabled
before_action
:verify_bitbucket_import_enabled
before_action
:bitbucket_auth
,
except: :callback
before_action
:bitbucket_auth
,
except: :callback
...
@@ -21,7 +23,7 @@ class Import::BitbucketController < Import::BaseController
...
@@ -21,7 +23,7 @@ class Import::BitbucketController < Import::BaseController
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
status
def
status
bitbucket_client
=
Bitbucket
::
Client
.
new
(
credentials
)
bitbucket_client
=
Bitbucket
::
Client
.
new
(
credentials
)
repos
=
bitbucket_client
.
repos
repos
=
bitbucket_client
.
repos
(
filter:
sanitized_filter_param
)
@repos
,
@incompatible_repos
=
repos
.
partition
{
|
repo
|
repo
.
valid?
}
@repos
,
@incompatible_repos
=
repos
.
partition
{
|
repo
|
repo
.
valid?
}
...
@@ -104,4 +106,8 @@ class Import::BitbucketController < Import::BaseController
...
@@ -104,4 +106,8 @@ class Import::BitbucketController < Import::BaseController
refresh_token:
session
[
:bitbucket_refresh_token
]
refresh_token:
session
[
:bitbucket_refresh_token
]
}
}
end
end
def
sanitized_filter_param
@filter
||=
sanitize
(
params
[
:filter
])
end
end
end
app/views/import/bitbucket/status.html.haml
浏览文件 @
7e5524bc
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
-
if
@repos
.
any?
-
if
@repos
.
any?
%p
.light
%p
.light
=
_
(
'Select projects you want to import.'
)
=
_
(
'Select projects you want to import.'
)
%hr
%p
%p
-
if
@incompatible_repos
.
any?
-
if
@incompatible_repos
.
any?
=
button_tag
class:
'btn btn-import btn-success js-import-all'
do
=
button_tag
class:
'btn btn-import btn-success js-import-all'
do
...
@@ -19,6 +18,15 @@
...
@@ -19,6 +18,15 @@
=
_
(
'Import all projects'
)
=
_
(
'Import all projects'
)
=
icon
(
'spinner spin'
,
class:
'loading-icon'
)
=
icon
(
'spinner spin'
,
class:
'loading-icon'
)
.position-relative.ms-no-clear.d-flex.flex-fill.float-right
=
form_tag
status_import_bitbucket_path
,
method:
'get'
do
=
text_field_tag
:filter
,
@filter
,
class:
'form-control append-bottom-10 pr-5'
,
placeholder:
_
(
'Filter projects'
),
size:
40
,
autofocus:
true
.position-absolute.position-top-0.d-flex.align-items-center.text-muted.position-right-0
{
style:
'margin-top: 1px'
}
%i
{
class:
'fa fa-times fa-lg pl-2 pr-2 cursor-pointer d-none'
,
'aria-hidden'
:
true
}
.border-left
%button
{
class:
'btn btn-transparent btn-secondary'
,
type:
'submit'
}
%i
{
class:
'fa fa-search'
,
'aria-hidden'
:
true
}
.table-responsive
.table-responsive
%table
.table.import-jobs
%table
.table.import-jobs
%colgroup
.import-jobs-from-col
%colgroup
.import-jobs-from-col
...
@@ -59,7 +67,7 @@
...
@@ -59,7 +67,7 @@
-
if
current_user
.
can_select_namespace?
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:current_user
-
selected
=
params
[
:namespace_id
]
||
:current_user
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
owner
,
path:
repo
.
owner
)
}
:
{}
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
repo
.
owner
,
path:
repo
.
owner
)
}
:
{}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'
input-group-text
select2 js-select-namespace'
,
tabindex:
1
}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
-
else
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-group-text input-large form-control"
,
tabindex:
1
,
disabled:
true
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-group-text input-large form-control"
,
tabindex:
1
,
disabled:
true
%span
.input-group-prepend
%span
.input-group-prepend
...
...
app/views/import/bitbucket_server/status.html.haml
浏览文件 @
7e5524bc
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
-
if
current_user
.
can_select_namespace?
-
if
current_user
.
can_select_namespace?
-
selected
=
params
[
:namespace_id
]
||
:extra_group
-
selected
=
params
[
:namespace_id
]
||
:extra_group
-
opts
=
current_user
.
can_create_group?
?
{
extra_group:
Group
.
new
(
name:
sanitize_project_name
(
repo
.
project_key
),
path:
sanitize_project_name
(
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
}
=
select_tag
:namespace_id
,
namespaces_options
(
selected
,
opts
.
merge
({
display_path:
true
})),
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
-
else
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-group-text input-large form-control"
,
tabindex:
1
,
disabled:
true
=
text_field_tag
:path
,
current_user
.
namespace_path
,
class:
"input-group-text input-large form-control"
,
tabindex:
1
,
disabled:
true
%span
.input-group-prepend
%span
.input-group-prepend
...
...
changelogs/unreleased/georgekoltsov-bitbucket-cloud-import-filtering.yml
0 → 100644
浏览文件 @
7e5524bc
---
title
:
Add project filtering to Bitbucket Cloud import
merge_request
:
32398
author
:
type
:
added
doc/user/project/import/bitbucket.md
浏览文件 @
7e5524bc
...
@@ -56,10 +56,10 @@ namespace that started the import process.
...
@@ -56,10 +56,10 @@ namespace that started the import process.
!
[
Grant access
](
img/bitbucket_import_grant_access.png
)
!
[
Grant access
](
img/bitbucket_import_grant_access.png
)
1.
Click on the projects that you'd like to import or
**Import all projects**
.
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
imported.
each project will be
imported.
!
[
Import projects
](
img/bitbucket_import_select_project.png
)
!
[
Import projects
](
img/bitbucket_import_select_project
_v12_3
.png
)
[
bb-import
]:
../../../integration/bitbucket.md
[
bb-import
]:
../../../integration/bitbucket.md
[
social sign-in
]:
../../profile/account/social_sign_in.md
[
social sign-in
]:
../../profile/account/social_sign_in.md
doc/user/project/import/img/bitbucket_import_select_project.png
已删除
100644 → 0
浏览文件 @
edd04207
8.5 KB
doc/user/project/import/img/bitbucket_import_select_project_v12_3.png
0 → 100644
浏览文件 @
7e5524bc
46.2 KB
lib/bitbucket/client.rb
浏览文件 @
7e5524bc
...
@@ -38,8 +38,10 @@ module Bitbucket
...
@@ -38,8 +38,10 @@ module Bitbucket
Representation
::
Repo
.
new
(
parsed_response
)
Representation
::
Repo
.
new
(
parsed_response
)
end
end
def
repos
def
repos
(
filter:
nil
)
path
=
"/repositories?role=member"
path
=
"/repositories?role=member"
path
+=
"&q=name~
\"
#{
filter
}
\"
"
if
filter
get_collection
(
path
,
:repo
)
get_collection
(
path
,
:repo
)
end
end
...
...
spec/controllers/import/bitbucket_controller_spec.rb
浏览文件 @
7e5524bc
...
@@ -80,6 +80,21 @@ describe Import::BitbucketController do
...
@@ -80,6 +80,21 @@ describe Import::BitbucketController do
expect
(
assigns
(
:already_added_projects
)).
to
eq
([
@project
])
expect
(
assigns
(
:already_added_projects
)).
to
eq
([
@project
])
expect
(
assigns
(
:repos
)).
to
eq
([])
expect
(
assigns
(
:repos
)).
to
eq
([])
end
end
context
'when filtering'
do
let
(
:filter
)
{
'<html>test</html>'
}
let
(
:expected_filter
)
{
'test'
}
subject
{
get
:status
,
params:
{
filter:
filter
},
as: :json
}
it
'passes sanitized filter param to bitbucket client'
do
expect_next_instance_of
(
Bitbucket
::
Client
)
do
|
client
|
expect
(
client
).
to
receive
(
:repos
).
with
(
filter:
expected_filter
).
and_return
([
@repo
])
end
subject
end
end
end
end
describe
"POST create"
do
describe
"POST create"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录