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
98194f17
Commit
98194f17
authored
Mar 22, 2019
by
Kamil Trzciński
Committed by
Stan Hu
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set proper default-branch on GitHub Import
parent
7ffc7982
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
changelogs/unreleased/retain-default-branch-on-import.yml
changelogs/unreleased/retain-default-branch-on-import.yml
+5
-0
lib/gitlab/github_import/importer/repository_importer.rb
lib/gitlab/github_import/importer/repository_importer.rb
+15
-1
spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
...gitlab/github_import/importer/repository_importer_spec.rb
+11
-0
No files found.
changelogs/unreleased/retain-default-branch-on-import.yml
0 → 100644
View file @
98194f17
---
title
:
Set proper default-branch for repository on GitHub Import
merge_request
:
26476
author
:
type
:
fixed
lib/gitlab/github_import/importer/repository_importer.rb
View file @
98194f17
...
...
@@ -5,6 +5,7 @@ module Gitlab
module
Importer
class
RepositoryImporter
include
Gitlab
::
ShellAdapter
include
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:project
,
:client
,
:wiki_formatter
...
...
@@ -17,7 +18,7 @@ module Gitlab
# Returns true if we should import the wiki for the project.
# rubocop: disable CodeReuse/ActiveRecord
def
import_wiki?
client
.
repository
(
project
.
import_source
)
&
.
has_wiki
&&
client
_repository
&
.
has_wiki
&&
!
project
.
wiki_repository_exists?
&&
Gitlab
::
GitalyClient
::
RemoteService
.
exists?
(
wiki_url
)
end
...
...
@@ -52,6 +53,7 @@ module Gitlab
refmap
=
Gitlab
::
GithubImport
.
refmap
project
.
repository
.
fetch_as_mirror
(
project
.
import_url
,
refmap:
refmap
,
forced:
true
,
remote_name:
'github'
)
project
.
change_head
(
default_branch
)
if
default_branch
true
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
,
Gitlab
::
Shell
::
Error
=>
e
fail_import
(
"Failed to import the repository:
#{
e
.
message
}
"
)
...
...
@@ -82,6 +84,18 @@ module Gitlab
project
.
import_state
.
mark_as_failed
(
message
)
false
end
private
def
default_branch
client_repository
&
.
default_branch
end
def
client_repository
strong_memoize
(
:client_repository
)
do
client
.
repository
(
project
.
import_source
)
end
end
end
end
end
...
...
spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
View file @
98194f17
...
...
@@ -179,6 +179,17 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
describe
'#import_repository'
do
it
'imports the repository'
do
repo
=
double
(
:repo
,
default_branch:
'develop'
)
expect
(
client
)
.
to
receive
(
:repository
)
.
with
(
'foo/bar'
)
.
and_return
(
repo
)
expect
(
project
)
.
to
receive
(
:change_head
)
.
with
(
'develop'
)
expect
(
project
)
.
to
receive
(
:ensure_repository
)
...
...
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