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
3fd704b2
Commit
3fd704b2
authored
Jul 20, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for BitBucketServer pull reuest parsing
parent
7c1aaf68
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
158 additions
and
12 deletions
+158
-12
lib/bitbucket_server/representation/pull_request.rb
lib/bitbucket_server/representation/pull_request.rb
+12
-12
spec/fixtures/importers/bitbucket_server/pull_request.json
spec/fixtures/importers/bitbucket_server/pull_request.json
+146
-0
No files found.
lib/bitbucket_server/representation/pull_request.rb
View file @
3fd704b2
...
@@ -2,11 +2,11 @@ module BitbucketServer
...
@@ -2,11 +2,11 @@ module BitbucketServer
module
Representation
module
Representation
class
PullRequest
<
Representation
::
Base
class
PullRequest
<
Representation
::
Base
def
author
def
author
raw
.
fetch
(
'author'
,
{}).
fetch
(
'user'
,
{}).
fetch
(
'name'
)
raw
.
dig
(
'author'
,
'user'
,
'name'
)
end
end
def
author_email
def
author_email
raw
.
fetch
(
'author'
,
{}).
fetch
(
'user'
,
{}).
fetch
(
'emailAddress'
)
raw
.
dig
(
'author'
,
'user'
,
'emailAddress'
)
end
end
def
description
def
description
...
@@ -32,11 +32,11 @@ module BitbucketServer
...
@@ -32,11 +32,11 @@ module BitbucketServer
end
end
def
created_at
def
created_at
raw
[
'createdDate'
]
Time
.
at
(
created_date
/
1000
)
if
created_date
.
is_a?
(
Integer
)
end
end
def
updated_at
def
updated_at
raw
[
'updatedDate'
]
Time
.
at
(
updated_date
/
1000
)
if
created_date
.
is_a?
(
Integer
)
end
end
def
title
def
title
...
@@ -44,29 +44,29 @@ module BitbucketServer
...
@@ -44,29 +44,29 @@ module BitbucketServer
end
end
def
source_branch_name
def
source_branch_name
source_branch
[
'id'
]
dig
(
'fromRef'
,
'id'
)
end
end
def
source_branch_sha
def
source_branch_sha
source_branch
[
'latestCommit'
]
dig
(
'fromRef'
,
'latestCommit'
)
end
end
def
target_branch_name
def
target_branch_name
target_branch
[
'id'
]
dig
(
'toRef'
,
'id'
)
end
end
def
target_branch_sha
def
target_branch_sha
target_branch
[
'latestCommit'
]
dig
(
'toRef'
,
'latestCommit'
)
end
end
private
private
def
source_branch
def
created_date
raw
[
'
fromRef'
]
||
{}
raw
[
'
createdDate'
]
end
end
def
target_branch
def
updated_date
raw
[
'
toRef'
]
||
{}
raw
[
'
updatedDate'
]
end
end
end
end
end
end
...
...
spec/fixtures/importers/bitbucket_server/pull_request.json
0 → 100644
View file @
3fd704b2
{
"author"
:{
"approved"
:
false
,
"role"
:
"AUTHOR"
,
"status"
:
"UNAPPROVED"
,
"user"
:{
"active"
:
true
,
"displayName"
:
"root"
,
"emailAddress"
:
"joe.montana@49ers.com"
,
"id"
:
1
,
"links"
:{
"self"
:[
{
"href"
:
"http://localhost:7990/users/root"
}
]
},
"name"
:
"root"
,
"slug"
:
"root"
,
"type"
:
"NORMAL"
}
},
"closed"
:
true
,
"closedDate"
:
1530600648850
,
"createdDate"
:
1530600635690
,
"description"
:
"Test"
,
"fromRef"
:{
"displayId"
:
"root/CODE_OF_CONDUCTmd-1530600625006"
,
"id"
:
"refs/heads/root/CODE_OF_CONDUCTmd-1530600625006"
,
"latestCommit"
:
"074e2b4dddc5b99df1bf9d4a3f66cfc15481fdc8"
,
"repository"
:{
"forkable"
:
true
,
"id"
:
1
,
"links"
:{
"clone"
:[
{
"href"
:
"http://root@localhost:7990/scm/test/rouge.git"
,
"name"
:
"http"
},
{
"href"
:
"ssh://git@localhost:7999/test/rouge.git"
,
"name"
:
"ssh"
}
],
"self"
:[
{
"href"
:
"http://localhost:7990/projects/TEST/repos/rouge/browse"
}
]
},
"name"
:
"rouge"
,
"project"
:{
"description"
:
"Test"
,
"id"
:
1
,
"key"
:
"TEST"
,
"links"
:{
"self"
:[
{
"href"
:
"http://localhost:7990/projects/TEST"
}
]
},
"name"
:
"test"
,
"public"
:
false
,
"type"
:
"NORMAL"
},
"public"
:
false
,
"scmId"
:
"git"
,
"slug"
:
"rouge"
,
"state"
:
"AVAILABLE"
,
"statusMessage"
:
"Available"
}
},
"id"
:
7
,
"links"
:{
"self"
:[
{
"href"
:
"http://localhost:7990/projects/TEST/repos/rouge/pull-requests/7"
}
]
},
"locked"
:
false
,
"open"
:
false
,
"participants"
:[
],
"properties"
:{
"commentCount"
:
1
,
"openTaskCount"
:
0
,
"resolvedTaskCount"
:
0
},
"reviewers"
:[
],
"state"
:
"MERGED"
,
"title"
:
"Added a new line"
,
"toRef"
:{
"displayId"
:
"master"
,
"id"
:
"refs/heads/master"
,
"latestCommit"
:
"839fa9a2d434eb697815b8fcafaecc51accfdbbc"
,
"repository"
:{
"forkable"
:
true
,
"id"
:
1
,
"links"
:{
"clone"
:[
{
"href"
:
"http://root@localhost:7990/scm/test/rouge.git"
,
"name"
:
"http"
},
{
"href"
:
"ssh://git@localhost:7999/test/rouge.git"
,
"name"
:
"ssh"
}
],
"self"
:[
{
"href"
:
"http://localhost:7990/projects/TEST/repos/rouge/browse"
}
]
},
"name"
:
"rouge"
,
"project"
:{
"description"
:
"Test"
,
"id"
:
1
,
"key"
:
"TEST"
,
"links"
:{
"self"
:[
{
"href"
:
"http://localhost:7990/projects/TEST"
}
]
},
"name"
:
"test"
,
"public"
:
false
,
"type"
:
"NORMAL"
},
"public"
:
false
,
"scmId"
:
"git"
,
"slug"
:
"rouge"
,
"state"
:
"AVAILABLE"
,
"statusMessage"
:
"Available"
}
},
"updatedDate"
:
1530600648850
,
"version"
:
2
}
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