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
e3bd1af7
Commit
e3bd1af7
authored
Jun 09, 2020
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement gitlab.com JSON status endpoint
This one reuses same serializers approach introduced in MR
parent
b9380cdf
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
91 additions
and
7 deletions
+91
-7
app/controllers/import/fogbugz_controller.rb
app/controllers/import/fogbugz_controller.rb
+0
-1
app/controllers/import/gitlab_controller.rb
app/controllers/import/gitlab_controller.rb
+28
-1
app/serializers/import/bitbucket_provider_repo_entity.rb
app/serializers/import/bitbucket_provider_repo_entity.rb
+0
-2
app/serializers/import/gitlab_provider_repo_entity.rb
app/serializers/import/gitlab_provider_repo_entity.rb
+19
-0
app/serializers/import/provider_repo_serializer.rb
app/serializers/import/provider_repo_serializer.rb
+2
-0
spec/controllers/import/bitbucket_controller_spec.rb
spec/controllers/import/bitbucket_controller_spec.rb
+1
-0
spec/controllers/import/bitbucket_server_controller_spec.rb
spec/controllers/import/bitbucket_server_controller_spec.rb
+1
-0
spec/controllers/import/fogbugz_controller_spec.rb
spec/controllers/import/fogbugz_controller_spec.rb
+1
-0
spec/controllers/import/gitlab_controller_spec.rb
spec/controllers/import/gitlab_controller_spec.rb
+10
-1
spec/serializers/import/gitlab_provider_repo_entity_spec.rb
spec/serializers/import/gitlab_provider_repo_entity_spec.rb
+27
-0
spec/support/shared_examples/controllers/import_controller_new_import_ui_shared_examples.rb
...ollers/import_controller_new_import_ui_shared_examples.rb
+2
-2
No files found.
app/controllers/import/fogbugz_controller.rb
View file @
e3bd1af7
...
...
@@ -90,7 +90,6 @@ class Import::FogbugzController < Import::BaseController
def
importable_repos
repos
=
client
.
repos
already_added_projects
=
find_already_added_projects
(
'fogbugz'
)
already_added_projects_names
=
already_added_projects
.
pluck
(
:import_source
)
repos
.
reject
{
|
repo
|
already_added_projects_names
.
include?
repo
.
name
}
...
...
app/controllers/import/gitlab_controller.rb
View file @
e3bd1af7
# frozen_string_literal: true
class
Import::GitlabController
<
Import
::
BaseController
extend
::
Gitlab
::
Utils
::
Override
MAX_PROJECT_PAGES
=
15
PER_PAGE_PROJECTS
=
100
...
...
@@ -16,6 +18,8 @@ class Import::GitlabController < Import::BaseController
# rubocop: disable CodeReuse/ActiveRecord
def
status
return
super
if
Feature
.
enabled?
(
:new_import_ui
)
@repos
=
client
.
projects
(
starting_page:
1
,
page_limit:
MAX_PROJECT_PAGES
,
per_page:
PER_PAGE_PROJECTS
)
@already_added_projects
=
find_already_added_projects
(
'gitlab'
)
...
...
@@ -37,7 +41,7 @@ class Import::GitlabController < Import::BaseController
project
=
Gitlab
::
GitlabImport
::
ProjectCreator
.
new
(
repo
,
target_namespace
,
current_user
,
access_params
).
execute
if
project
.
persisted?
render
json:
ProjectSerializer
.
new
.
represent
(
project
)
render
json:
ProjectSerializer
.
new
.
represent
(
project
,
serializer: :import
)
else
render
json:
{
errors:
project_save_error
(
project
)
},
status: :unprocessable_entity
end
...
...
@@ -46,6 +50,29 @@ class Import::GitlabController < Import::BaseController
end
end
protected
# rubocop: disable CodeReuse/ActiveRecord
override
:importable_repos
def
importable_repos
repos
=
client
.
projects
(
starting_page:
1
,
page_limit:
MAX_PROJECT_PAGES
,
per_page:
PER_PAGE_PROJECTS
)
already_added_projects_names
=
already_added_projects
.
pluck
(
:import_source
)
repos
.
reject
{
|
repo
|
already_added_projects_names
.
include?
repo
[
"path_with_namespace"
]
}
end
# rubocop: enable CodeReuse/ActiveRecord
override
:provider_name
def
provider_name
:gitlab
end
override
:provider_url
def
provider_url
'https://gitlab.com'
end
private
def
client
...
...
app/serializers/import/bitbucket_provider_repo_entity.rb
View file @
e3bd1af7
# frozen_string_literal: true
class
Import::BitbucketProviderRepoEntity
<
Import
::
BaseProviderRepoEntity
include
ImportHelper
expose
:id
,
override:
true
do
|
repo
|
repo
.
full_name
end
...
...
app/serializers/import/gitlab_provider_repo_entity.rb
0 → 100644
View file @
e3bd1af7
# frozen_string_literal: true
class
Import::GitlabProviderRepoEntity
<
Import
::
BaseProviderRepoEntity
expose
:id
,
override:
true
do
|
repo
|
repo
[
"id"
]
end
expose
:full_name
,
override:
true
do
|
repo
|
repo
[
"path_with_namespace"
]
end
expose
:sanitized_name
,
override:
true
do
|
repo
|
repo
[
"path"
]
end
expose
:provider_link
,
override:
true
do
|
repo
|
repo
[
"web_url"
]
end
end
app/serializers/import/provider_repo_serializer.rb
View file @
e3bd1af7
...
...
@@ -12,6 +12,8 @@ class Import::ProviderRepoSerializer < BaseSerializer
Import
::
BitbucketProviderRepoEntity
when
:bitbucket_server
Import
::
BitbucketServerProviderRepoEntity
when
:gitlab
Import
::
GitlabProviderRepoEntity
else
raise
NotImplementedError
end
...
...
spec/controllers/import/bitbucket_controller_spec.rb
View file @
e3bd1af7
...
...
@@ -70,6 +70,7 @@ RSpec.describe Import::BitbucketController do
let
(
:repo_id
)
{
@repo
.
full_name
}
let
(
:import_source
)
{
@repo
.
full_name
}
let
(
:provider_name
)
{
'bitbucket'
}
let
(
:client_repos_field
)
{
:repos
}
end
it
"assigns variables"
do
...
...
spec/controllers/import/bitbucket_server_controller_spec.rb
View file @
e3bd1af7
...
...
@@ -153,6 +153,7 @@ RSpec.describe Import::BitbucketServerController do
let
(
:repo_id
)
{
@repo
.
full_name
}
let
(
:import_source
)
{
@repo
.
browse_url
}
let
(
:provider_name
)
{
'bitbucket_server'
}
let
(
:client_repos_field
)
{
:repos
}
end
it
'assigns repository categories'
do
...
...
spec/controllers/import/fogbugz_controller_spec.rb
View file @
e3bd1af7
...
...
@@ -90,6 +90,7 @@ RSpec.describe Import::FogbugzController do
let
(
:repo_id
)
{
@repo
.
id
}
let
(
:import_source
)
{
@repo
.
name
}
let
(
:provider_name
)
{
'fogbugz'
}
let
(
:client_repos_field
)
{
:repos
}
end
it
'assigns variables'
do
...
...
spec/controllers/import/gitlab_controller_spec.rb
View file @
e3bd1af7
...
...
@@ -34,8 +34,17 @@ RSpec.describe Import::GitlabController do
describe
"GET status"
do
before
do
@repo
=
OpenStruct
.
new
(
path:
'vim'
,
path_with_namespace:
'
asd/vim'
)
@repo
=
OpenStruct
.
new
(
id:
1
,
path:
'vim'
,
path_with_namespace:
'asd/vim'
,
web_url:
'https://gitlab.com/
asd/vim'
)
assign_session_token
stub_feature_flags
(
new_import_ui:
false
)
end
it_behaves_like
'import controller with new_import_ui feature flag'
do
let
(
:repo
)
{
@repo
}
let
(
:repo_id
)
{
@repo
.
id
}
let
(
:import_source
)
{
@repo
.
path_with_namespace
}
let
(
:provider_name
)
{
'gitlab'
}
let
(
:client_repos_field
)
{
:projects
}
end
it
"assigns variables"
do
...
...
spec/serializers/import/gitlab_provider_repo_entity_spec.rb
0 → 100644
View file @
e3bd1af7
# frozen_string_literal: true
require
'spec_helper'
describe
Import
::
GitlabProviderRepoEntity
do
let
(
:repo_data
)
do
{
'id'
=>
1
,
'path_with_namespace'
=>
'demo/test'
,
'path'
=>
'test'
,
'web_url'
=>
'https://gitlab.com/demo/test'
}
end
subject
{
described_class
.
new
(
repo_data
).
as_json
}
it_behaves_like
'exposes required fields for import entity'
do
let
(
:expected_values
)
do
{
id:
1
,
full_name:
'demo/test'
,
sanitized_name:
'test'
,
provider_link:
'https://gitlab.com/demo/test'
}
end
end
end
spec/support/shared_examples/controllers/import_controller_new_import_ui_shared_examples.rb
View file @
e3bd1af7
...
...
@@ -13,7 +13,7 @@ RSpec.shared_examples 'import controller with new_import_ui feature flag' do
it
"returns variables for json request"
do
project
=
create
(
:project
,
import_type:
provider_name
,
creator_id:
user
.
id
)
stub_client
(
repos:
[
repo
])
stub_client
(
client_repos_field
=>
[
repo
])
get
:status
,
format: :json
...
...
@@ -25,7 +25,7 @@ RSpec.shared_examples 'import controller with new_import_ui feature flag' do
it
"does not show already added project"
do
project
=
create
(
:project
,
import_type:
provider_name
,
namespace:
user
.
namespace
,
import_status: :finished
,
import_source:
import_source
)
stub_client
(
repos:
[
repo
],
orgs:
[
])
stub_client
(
client_repos_field
=>
[
repo
])
get
:status
,
format: :json
...
...
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