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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
8aafe685
Commit
8aafe685
authored
Mar 22, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first round of fixes and spec fixes
parent
3b78885e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
37 deletions
+39
-37
app/models/project.rb
app/models/project.rb
+3
-2
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+1
-18
lib/gitlab/bitbucket_import/importer_init.rb
lib/gitlab/bitbucket_import/importer_init.rb
+27
-0
lib/gitlab/bitbucket_import/key_deleter.rb
lib/gitlab/bitbucket_import/key_deleter.rb
+2
-11
lib/gitlab/bitbucket_import/project_creator.rb
lib/gitlab/bitbucket_import/project_creator.rb
+2
-2
spec/lib/gitlab/bitbucket_import/importer_spec.rb
spec/lib/gitlab/bitbucket_import/importer_spec.rb
+4
-4
No files found.
app/models/project.rb
View file @
8aafe685
...
...
@@ -407,7 +407,7 @@ class Project < ActiveRecord::Base
end
def
import_url
if
import_data
if
import_data
&&
super
import_url
=
Gitlab
::
ImportUrl
.
new
(
super
,
credentials:
import_data
.
credentials
)
import_url
.
full_url
else
...
...
@@ -417,7 +417,8 @@ class Project < ActiveRecord::Base
def
create_or_update_import_data
(
credentials
)
project_import_data
=
import_data
||
build_import_data
project_import_data
.
credentials
=
credentials
project_import_data
.
credentials
||=
{}
project_import_data
.
credentials
.
merge!
(
credentials
)
project_import_data
.
save
end
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
8aafe685
module
Gitlab
module
BitbucketImport
class
Importer
attr_reader
:project
,
:client
def
initialize
(
project
)
@project
=
project
if
import_data_credentials
&&
import_data_credentials
[
'bb_session'
]
token
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token'
]
token_secret
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token_secret'
]
@client
=
Client
.
new
(
token
,
token_secret
)
@formatter
=
Gitlab
::
ImportFormatter
.
new
else
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
end
end
class
Importer
<
ImporterInit
def
execute
import_issues
if
has_issues?
...
...
@@ -27,10 +14,6 @@ module Gitlab
private
def
import_data_credentials
@import_data_credentials
||=
project
.
import_data
.
credentials
if
project
.
import_data
end
def
gl_user_id
(
project
,
bitbucket_id
)
if
bitbucket_id
user
=
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
bitbucket_id
.
to_s
)
...
...
lib/gitlab/bitbucket_import/importer_init.rb
0 → 100644
View file @
8aafe685
module
Gitlab
module
BitbucketImport
class
ImporterInit
attr_reader
:project
,
:client
def
initialize
(
project
)
@project
=
project
if
import_data_credentials
&&
import_data_credentials
[
'bb_session'
]
token
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token'
]
token_secret
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token_secret'
]
@client
=
Client
.
new
(
token
,
token_secret
)
@formatter
=
Gitlab
::
ImportFormatter
.
new
else
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
end
end
private
def
import_data_credentials
@import_data_credentials
||=
project
.
import_data
.
credentials
if
project
.
import_data
end
end
end
end
lib/gitlab/bitbucket_import/key_deleter.rb
View file @
8aafe685
module
Gitlab
module
BitbucketImport
class
KeyDeleter
attr_reader
:project
,
:current_user
,
:client
def
initialize
(
project
)
@project
=
project
@current_user
=
project
.
creator
import_data
=
project
.
import_data
.
try
(
:data
)
bb_session
=
import_data
[
"bb_session"
]
if
import_data
@client
=
Client
.
new
(
bb_session
[
"bitbucket_access_token"
],
bb_session
[
"bitbucket_access_token_secret"
])
end
class
KeyDeleter
<
ImporterInit
attr_reader
:current_user
def
execute
return
false
unless
BitbucketImport
.
public_key
.
present?
...
...
lib/gitlab/bitbucket_import/project_creator.rb
View file @
8aafe685
...
...
@@ -22,8 +22,8 @@ module Gitlab
import_source:
"
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
"
,
import_url:
"ssh://git@bitbucket.org/
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
.git"
,
).
execute
project
.
create_import_data
(
credentials:
{
"bb_session"
=>
session_data
}
)
import_data
=
project
.
import_data
import_data
.
credentials
.
merge!
(
"bb_session"
=>
session_data
)
project
end
end
...
...
spec/lib/gitlab/bitbucket_import/importer_spec.rb
View file @
8aafe685
...
...
@@ -34,9 +34,9 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
let
(
:project_identifier
)
{
'namespace/repo'
}
let
(
:data
)
do
{
bb_session:
{
bitbucket_access_token:
"123456"
,
bitbucket_access_token_secret:
"secret"
'bb_session'
=>
{
'bitbucket_access_token'
=>
"123456"
,
'bitbucket_access_token_secret'
=>
"secret"
}
}
end
...
...
@@ -44,7 +44,7 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
create
(
:project
,
import_source:
project_identifier
,
import_data:
ProjectImportData
.
new
(
data
:
data
)
import_data:
ProjectImportData
.
new
(
credentials
:
data
)
)
end
let
(
:importer
)
{
Gitlab
::
BitbucketImport
::
Importer
.
new
(
project
)
}
...
...
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