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
Boxiang Sun
gitlab-ce
Commits
e72aeccd
Commit
e72aeccd
authored
Sep 17, 2018
by
James Lopez
Committed by
Douwe Maan
Sep 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Unable to import repository: undefined method `import_file' for nil:NilClass"
parent
78b3eea7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
4 deletions
+15
-4
app/controllers/import/gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+6
-2
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-1
changelogs/unreleased/50944-unable-to-import-repository-undefined-method-import_file-for-nil-nilclass.yml
...ository-undefined-method-import_file-for-nil-nilclass.yml
+5
-0
spec/controllers/import/gitlab_projects_controller_spec.rb
spec/controllers/import/gitlab_projects_controller_spec.rb
+1
-1
spec/features/projects/import_export/export_file_spec.rb
spec/features/projects/import_export/export_file_spec.rb
+2
-0
No files found.
app/controllers/import/gitlab_projects_controller.rb
View file @
e72aeccd
...
@@ -11,7 +11,7 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -11,7 +11,7 @@ class Import::GitlabProjectsController < Import::BaseController
def
create
def
create
unless
file_is_valid?
unless
file_is_valid?
return
redirect_back_or_default
(
options:
{
alert:
"You need to upload a GitLab project export archive."
})
return
redirect_back_or_default
(
options:
{
alert:
"You need to upload a GitLab project export archive
(ending in .gz)
."
})
end
end
@project
=
::
Projects
::
GitlabProjectsImportService
.
new
(
current_user
,
project_params
).
execute
@project
=
::
Projects
::
GitlabProjectsImportService
.
new
(
current_user
,
project_params
).
execute
...
@@ -29,7 +29,11 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -29,7 +29,11 @@ class Import::GitlabProjectsController < Import::BaseController
private
private
def
file_is_valid?
def
file_is_valid?
project_params
[
:file
]
&&
project_params
[
:file
].
respond_to?
(
:read
)
return
false
unless
project_params
[
:file
]
&&
project_params
[
:file
].
respond_to?
(
:read
)
filename
=
project_params
[
:file
].
original_filename
ImportExportUploader
::
EXTENSION_WHITELIST
.
include?
(
File
.
extname
(
filename
).
delete
(
'.'
))
end
end
def
verify_gitlab_project_import_enabled
def
verify_gitlab_project_import_enabled
...
...
app/controllers/projects_controller.rb
View file @
e72aeccd
...
@@ -196,7 +196,7 @@ class ProjectsController < Projects::ApplicationController
...
@@ -196,7 +196,7 @@ class ProjectsController < Projects::ApplicationController
def
download_export
def
download_export
if
@project
.
export_file_exists?
if
@project
.
export_file_exists?
send_upload
(
@project
.
export_file
)
send_upload
(
@project
.
export_file
,
attachment:
@project
.
export_file
.
filename
)
else
else
redirect_to
(
redirect_to
(
edit_project_path
(
@project
,
anchor:
'js-export-project'
),
edit_project_path
(
@project
,
anchor:
'js-export-project'
),
...
...
changelogs/unreleased/50944-unable-to-import-repository-undefined-method-import_file-for-nil-nilclass.yml
0 → 100644
View file @
e72aeccd
---
title
:
Fix import error when archive does not have the correct extension
merge_request
:
21765
author
:
type
:
fixed
spec/controllers/import/gitlab_projects_controller_spec.rb
View file @
e72aeccd
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Import
::
GitlabProjectsController
do
describe
Import
::
GitlabProjectsController
do
set
(
:namespace
)
{
create
(
:namespace
)
}
set
(
:namespace
)
{
create
(
:namespace
)
}
set
(
:user
)
{
namespace
.
owner
}
set
(
:user
)
{
namespace
.
owner
}
let
(
:file
)
{
fixture_file_upload
(
'spec/fixtures/
doc_sample.txt
'
,
'text/plain'
)
}
let
(
:file
)
{
fixture_file_upload
(
'spec/fixtures/
project_export.tar.gz
'
,
'text/plain'
)
}
before
do
before
do
sign_in
(
user
)
sign_in
(
user
)
...
...
spec/features/projects/import_export/export_file_spec.rb
View file @
e72aeccd
...
@@ -49,6 +49,8 @@ describe 'Import/Export - project export integration test', :js do
...
@@ -49,6 +49,8 @@ describe 'Import/Export - project export integration test', :js do
expect
(
file_permissions
(
project
.
export_path
)).
to
eq
(
0700
)
expect
(
file_permissions
(
project
.
export_path
)).
to
eq
(
0700
)
expect
(
project
.
export_file
.
path
).
to
include
(
'tar.gz'
)
in_directory_with_expanded_export
(
project
)
do
|
exit_status
,
tmpdir
|
in_directory_with_expanded_export
(
project
)
do
|
exit_status
,
tmpdir
|
expect
(
exit_status
).
to
eq
(
0
)
expect
(
exit_status
).
to
eq
(
0
)
...
...
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