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
Jérome Perrin
gitlab-ce
Commits
81995317
Commit
81995317
authored
Jul 14, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use project.import_url to fetch repositories from Github
parent
66e7b4cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
lib/github/import.rb
lib/github/import.rb
+10
-9
lib/tasks/import.rake
lib/tasks/import.rake
+1
-0
No files found.
lib/github/import.rb
View file @
81995317
...
@@ -41,13 +41,16 @@ module Github
...
@@ -41,13 +41,16 @@ module Github
self
.
reset_callbacks
:validate
self
.
reset_callbacks
:validate
end
end
attr_reader
:project
,
:repository
,
:repo
,
:options
,
:errors
,
:cached
,
:verbose
attr_reader
:project
,
:repository
,
:repo
,
:repo_url
,
:wiki_url
,
:options
,
:errors
,
:cached
,
:verbose
def
initialize
(
project
,
options
)
def
initialize
(
project
,
options
)
@project
=
project
@project
=
project
@repository
=
project
.
repository
@repository
=
project
.
repository
@repo
=
project
.
import_source
@repo
=
project
.
import_source
@options
=
options
@options
=
options
@repo_url
=
project
.
import_url
@wiki_url
=
project
.
import_url
.
sub
(
/\.git\z/
,
'.wiki.git'
)
@verbose
=
options
.
fetch
(
:verbose
,
false
)
@verbose
=
options
.
fetch
(
:verbose
,
false
)
@cached
=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
Hash
.
new
}
@cached
=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
Hash
.
new
}
@errors
=
[]
@errors
=
[]
...
@@ -81,23 +84,21 @@ module Github
...
@@ -81,23 +84,21 @@ module Github
def
fetch_repository
def
fetch_repository
begin
begin
project
.
create_repository
unless
project
.
repository
.
exists?
project
.
ensure_repository
project
.
repository
.
add_remote
(
'github'
,
"https://
#{
options
.
fetch
(
:token
)
}
@github.com/
#{
repo
}
.git"
)
project
.
repository
.
add_remote
(
'github'
,
repo_url
)
project
.
repository
.
set_remote_as_mirror
(
'github'
)
project
.
repository
.
set_remote_as_mirror
(
'github'
)
project
.
repository
.
fetch_remote
(
'github'
,
forced:
true
)
project
.
repository
.
fetch_remote
(
'github'
,
forced:
true
)
rescue
Gitlab
::
Shell
::
Error
=>
e
rescue
Gitlab
::
Shell
::
Error
=>
e
error
(
:project
,
"https://github.com/
#{
repo
}
.git"
,
e
.
message
)
error
(
:project
,
repo_url
,
e
.
message
)
raise
Github
::
RepositoryFetchError
raise
Github
::
RepositoryFetchError
end
end
end
end
def
fetch_wiki_repository
def
fetch_wiki_repository
wiki_url
=
"https://
#{
options
.
fetch
(
:token
)
}
@github.com/
#{
repo
}
.wiki.git"
return
if
project
.
wiki
.
repository_exists?
wiki_path
=
"
#{
project
.
full_path
}
.wiki"
unless
project
.
wiki
.
repository_exists?
wiki_path
=
"
#{
project
.
path_with_namespace
}
.wiki"
gitlab_shell
.
import_repository
(
project
.
repository_storage_path
,
wiki_path
,
wiki_url
)
gitlab_shell
.
import_repository
(
project
.
repository_storage_path
,
wiki_path
,
wiki_url
)
end
rescue
Gitlab
::
Shell
::
Error
=>
e
rescue
Gitlab
::
Shell
::
Error
=>
e
# GitHub error message when the wiki repo has not been created,
# GitHub error message when the wiki repo has not been created,
# this means that repo has wiki enabled, but have no pages. So,
# this means that repo has wiki enabled, but have no pages. So,
...
...
lib/tasks/import.rake
View file @
81995317
...
@@ -62,6 +62,7 @@ class GithubImport
...
@@ -62,6 +62,7 @@ class GithubImport
visibility_level:
visibility_level
,
visibility_level:
visibility_level
,
import_type:
'github'
,
import_type:
'github'
,
import_source:
@repo
[
'full_name'
],
import_source:
@repo
[
'full_name'
],
import_url:
@repo
[
'clone_url'
].
sub
(
'://'
,
"://
#{
options
[
:token
]
}
@"
),
skip_wiki:
@repo
[
'has_wiki'
]
skip_wiki:
@repo
[
'has_wiki'
]
).
execute
).
execute
end
end
...
...
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