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
Tatuya Kamada
gitlab-ce
Commits
704115c7
Commit
704115c7
authored
Aug 22, 2016
by
Douglas Barbosa Alexandre
Committed by
Stan Hu
Nov 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import opened pull request from Bitbucket
parent
64722a15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
lib/bitbucket/representation/pull_request.rb
lib/bitbucket/representation/pull_request.rb
+59
-0
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+31
-0
No files found.
lib/bitbucket/representation/pull_request.rb
View file @
704115c7
module
Bitbucket
module
Representation
class
PullRequest
<
Representation
::
Base
def
author
raw
.
fetch
(
'author'
,
{}).
fetch
(
'username'
,
'Anonymous'
)
end
def
description
raw
[
'description'
]
end
def
iid
raw
[
'id'
]
end
def
state
if
raw
[
'state'
]
==
'MERGED'
'merged'
elsif
raw
[
'state'
]
==
'DECLINED'
'closed'
else
'opened'
end
end
def
created_at
raw
[
'created_on'
]
end
def
updated_at
raw
[
'updated_on'
]
end
def
title
raw
[
'title'
]
end
def
source_branch_name
source_branch
.
dig
(
'branch'
,
'name'
)
end
def
source_branch_sha
source_branch
.
dig
(
'commit'
,
'hash'
)
end
def
target_branch_name
target_branch
.
dig
(
'branch'
,
'name'
)
end
def
target_branch_sha
target_branch
.
dig
(
'commit'
,
'hash'
)
end
private
def
source_branch
raw
[
'source'
]
end
def
target_branch
raw
[
'destination'
]
end
end
end
end
lib/gitlab/bitbucket_import/importer.rb
View file @
704115c7
...
...
@@ -11,6 +11,7 @@ module Gitlab
def
execute
import_issues
import_pull_requests
true
end
...
...
@@ -72,6 +73,36 @@ module Gitlab
rescue
ActiveRecord
::
RecordInvalid
nil
end
def
import_pull_requests
pull_requests
=
client
.
pull_requests
(
repo
)
pull_requests
.
each
do
|
pull_request
|
begin
description
=
@formatter
.
author_line
(
pull_request
.
author
)
description
+=
pull_request
.
description
project
.
merge_requests
.
create
(
iid:
pull_request
.
iid
,
title:
pull_request
.
title
,
description:
description
,
source_project:
project
,
source_branch:
pull_request
.
source_branch_name
,
source_branch_sha:
pull_request
.
source_branch_sha
,
target_project:
project
,
target_branch:
pull_request
.
target_branch_name
,
target_branch_sha:
pull_request
.
target_branch_sha
,
state:
pull_request
.
state
,
author_id:
gl_user_id
(
project
,
pull_request
.
author
),
assignee_id:
nil
,
created_at:
pull_request
.
created_at
,
updated_at:
pull_request
.
updated_at
)
rescue
ActiveRecord
::
RecordInvalid
nil
end
end
end
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