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
Kazuhiko Shiozaki
gitlab-ce
Commits
78f5eb94
Commit
78f5eb94
authored
Jan 06, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import GitHub wiki into GitLab
parent
e47f0e56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
1 deletion
+56
-1
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+13
-0
lib/gitlab/github_import/project_creator.rb
lib/gitlab/github_import/project_creator.rb
+2
-1
lib/gitlab/github_import/wiki_formatter.rb
lib/gitlab/github_import/wiki_formatter.rb
+19
-0
spec/lib/gitlab/github_import/wiki_formatter_spec.rb
spec/lib/gitlab/github_import/wiki_formatter_spec.rb
+22
-0
No files found.
lib/gitlab/github_import/importer.rb
View file @
78f5eb94
module
Gitlab
module
GithubImport
class
Importer
include
Gitlab
::
ShellAdapter
attr_reader
:project
,
:client
def
initialize
(
project
)
...
...
@@ -14,8 +16,11 @@ module Gitlab
def
execute
import_issues
import_pull_requests
import_wiki
true
rescue
Gitlab
::
Shell
::
Error
false
end
private
...
...
@@ -66,6 +71,14 @@ module Gitlab
noteable
.
notes
.
create!
(
comment
.
attributes
)
end
end
def
import_wiki
unless
project
.
wiki_enabled?
wiki
=
WikiFormatter
.
new
(
project
)
gitlab_shell
.
import_repository
(
wiki
.
path_with_namespace
,
wiki
.
import_url
)
project
.
update_attribute
(
:wiki_enabled
,
true
)
end
end
end
end
end
lib/gitlab/github_import/project_creator.rb
View file @
78f5eb94
...
...
@@ -20,7 +20,8 @@ module Gitlab
visibility_level:
repo
.
private
?
Gitlab
::
VisibilityLevel
::
PRIVATE
:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
import_type:
"github"
,
import_source:
repo
.
full_name
,
import_url:
repo
.
clone_url
.
sub
(
"https://"
,
"https://
#{
@session_data
[
:github_access_token
]
}
@"
)
import_url:
repo
.
clone_url
.
sub
(
"https://"
,
"https://
#{
@session_data
[
:github_access_token
]
}
@"
),
wiki_enabled:
!
repo
.
has_wiki?
# If repo has wiki we'll import it later
).
execute
project
.
create_import_data
(
data:
{
"github_session"
=>
session_data
}
)
...
...
lib/gitlab/github_import/wiki_formatter.rb
0 → 100644
View file @
78f5eb94
module
Gitlab
module
GithubImport
class
WikiFormatter
attr_reader
:project
def
initialize
(
project
)
@project
=
project
end
def
path_with_namespace
"
#{
project
.
path_with_namespace
}
.wiki"
end
def
import_url
project
.
import_url
.
sub
(
".git"
,
".wiki.git"
)
end
end
end
end
spec/lib/gitlab/github_import/wiki_formatter_spec.rb
0 → 100644
View file @
78f5eb94
require
'spec_helper'
describe
Gitlab
::
GithubImport
::
WikiFormatter
,
lib:
true
do
let
(
:project
)
do
create
(
:project
,
namespace:
create
(
:namespace
,
path:
'gitlabhq'
),
import_url:
'https://xxx@github.com/gitlabhq/gitlabhq.git'
)
end
subject
(
:wiki
)
{
described_class
.
new
(
project
)}
describe
'#path_with_namespace'
do
it
'appends .wiki to project path'
do
expect
(
wiki
.
path_with_namespace
).
to
eq
'gitlabhq/gitlabhq.wiki'
end
end
describe
'#import_url'
do
it
'returns URL of the wiki repository'
do
expect
(
wiki
.
import_url
).
to
eq
'https://xxx@github.com/gitlabhq/gitlabhq.wiki.git'
end
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