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
bd9e5c5d
Commit
bd9e5c5d
authored
Apr 19, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clone GitHub wiki
parent
3c0a713a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
lib/github/import.rb
lib/github/import.rb
+21
-2
No files found.
lib/github/import.rb
View file @
bd9e5c5d
module
Github
class
Import
class
MergeRequest
<
::
MergeRequest
self
.
table_name
=
'merge_requests'
...
...
@@ -47,6 +48,7 @@ module Github
fetch_milestones
fetch_pull_requests
fetch_issues
fetch_wiki_repository
expire_repository_cache
errors
...
...
@@ -57,7 +59,7 @@ module Github
def
fetch_repository
begin
project
.
create_repository
project
.
repository
.
add_remote
(
'github'
,
"https://{
token
}@github.com/
#{
repo
}
.git"
)
project
.
repository
.
add_remote
(
'github'
,
"https://{
options.fetch(:token)
}@github.com/
#{
repo
}
.git"
)
project
.
repository
.
set_remote_as_mirror
(
'github'
)
project
.
repository
.
fetch_remote
(
'github'
,
forced:
true
)
rescue
Gitlab
::
Shell
::
Error
=>
e
...
...
@@ -65,6 +67,22 @@ module Github
end
end
def
fetch_wiki_repository
wiki_url
=
"https://{options.fetch(:token)}@github.com/
#{
repo
}
.wiki.git"
wiki_path
=
"
#{
project
.
path_with_namespace
}
.wiki"
unless
project
.
wiki
.
repository_exists?
gitlab_shell
.
import_repository
(
project
.
repository_storage_path
,
wiki_path
,
wiki_url
)
end
rescue
Gitlab
::
Shell
::
Error
=>
e
# GitHub error message when the wiki repo has not been created,
# this means that repo has wiki enabled, but have no pages. So,
# we can skip the import.
if
e
.
message
!~
/repository not exported/
errors
(
:wiki
,
wiki_url
,
e
.
message
)
end
end
def
fetch_labels
url
=
"/repos/
#{
repo
}
/labels"
...
...
@@ -163,6 +181,7 @@ module Github
comments_url
=
"/repos/
#{
repo
}
/issues/
#{
pull_request
.
iid
}
/comments"
fetch_comments
(
merge_request
,
:comment
,
comments_url
)
rescue
=>
e
error
(
:pull_request
,
pull_request
.
url
,
e
.
message
)
ensure
clean_up_restored_branches
(
pull_request
)
end
...
...
@@ -209,8 +228,8 @@ module Github
issue
.
updated_at
=
representation
.
updated_at
issue
.
save!
(
validate:
false
)
# Fetch comments
if
representation
.
has_comments?
# Fetch comments
comments_url
=
"/repos/
#{
repo
}
/issues/
#{
issue
.
iid
}
/comments"
fetch_comments
(
issue
,
:comment
,
comments_url
)
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