Skip to content

Commit

Permalink
[WIP] Set comment as Markdown, Getting comments from API instead of f…
Browse files Browse the repository at this point in the history
…iltering from activities
  • Loading branch information
HelloCore committed Jun 24, 2019
1 parent 5bfa67f commit ce1f631
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 215 deletions.
2 changes: 1 addition & 1 deletion source/platforms/BitBucketCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class BitBucketCloud implements Platform {
}

const commits = await this.api.getPullRequestCommits()
const comments = await this.api.getPullRequestComments()
const activities = await this.api.getPullRequestActivities()
const comments = await this.api.getPullRequestComments(activities)
return {
metadata: this.api.repoMetadata,
pr,
Expand Down
164 changes: 67 additions & 97 deletions source/platforms/_tests/__snapshots__/_bitbucket_cloud.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2439,9 +2439,8 @@ Object {
exports[`getPlatformReviewDSLRepresentation should get the reviewer comments 1`] = `
Array [
Object {
"comment": Object {
"content": Object {
"html": "<p>⚠️ 1 Warning. Don't worry, everything is fixable.</p>
"content": Object {
"html": "<p>⚠️ 1 Warning. Don't worry, everything is fixable.</p>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -2471,8 +2470,8 @@ Array [
</tbody>
</table>
<p>Generated by <a data-is-external-link=\\"true\\" href=\\"https://danger.systems/\\" rel=\\"nofollow\\" title=\\"generated_by_danger\\">Danger</a></p>",
"markup": "markdown",
"raw": "⚠️ 1 Warning. Don't worry, everything is fixable.
"markup": "markdown",
"raw": "⚠️ 1 Warning. Don't worry, everything is fixable.
| | 1 Warning |
|---|---|
Expand All @@ -2486,54 +2485,20 @@ Array [
Generated by [Danger](https://danger.systems/ \\"generated_by_danger\\")
",
"type": "rendered",
},
"created_on": "2019-06-20T04:53:23.618489+00:00",
"deleted": false,
"id": 106400843,
"links": Object {
"html": Object {
"href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106400843",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106400843",
},
},
"pullrequest": Object {
"id": 324,
"links": Object {
"html": Object {
"href": "https://bitbucket.org/foo/bar/pull-requests/324",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324",
},
},
"title": "Test PR Title",
"type": "pullrequest",
"type": "rendered",
},
"created_on": "2019-06-20T04:53:23.618489+00:00",
"deleted": false,
"id": 106400843,
"links": Object {
"html": Object {
"href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106400843",
},
"type": "pullrequest_comment",
"updated_on": "2019-06-20T04:53:23.680568+00:00",
"user": Object {
"account_id": "5b3b3d9c50b3772e6bbda9f8",
"display_name": "DangerCI",
"links": Object {
"avatar": Object {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128",
},
"html": Object {
"href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D",
},
},
"nickname": "DangerCI",
"type": "user",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
"self": Object {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106400843",
},
},
"pull_request": Object {
"pullrequest": Object {
"id": 324,
"links": Object {
"html": Object {
Expand All @@ -2546,62 +2511,47 @@ Generated by [Danger](https://danger.systems/ \\"generated_by_danger\\")
"title": "Test PR Title",
"type": "pullrequest",
},
},
Object {
"comment": Object {
"content": Object {
"html": "<p>remove this file</p>",
"markup": "markdown",
"raw": "remove this file",
"type": "rendered",
},
"created_on": "2019-06-18T18:23:19.626793+00:00",
"deleted": false,
"id": 106174425,
"inline": Object {},
"type": "pullrequest_comment",
"updated_on": "2019-06-20T04:53:23.680568+00:00",
"user": Object {
"account_id": "5b3b3d9c50b3772e6bbda9f8",
"display_name": "DangerCI",
"links": Object {
"avatar": Object {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128",
},
"html": Object {
"href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106174425",
"href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106174425",
"href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D",
},
},
"pullrequest": Object {
"id": 324,
"links": Object {
"html": Object {
"href": "https://bitbucket.org/foo/bar/pull-requests/324",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324",
},
},
"title": "Test PR Title",
"type": "pullrequest",
"nickname": "DangerCI",
"type": "user",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
},
},
Object {
"content": Object {
"html": "<p>remove this file</p>",
"markup": "markdown",
"raw": "remove this file",
"type": "rendered",
},
"created_on": "2019-06-18T18:23:19.626793+00:00",
"deleted": false,
"id": 106174425,
"inline": Object {},
"links": Object {
"html": Object {
"href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106174425",
},
"type": "pullrequest_comment",
"updated_on": "2019-06-18T18:23:19.636448+00:00",
"user": Object {
"account_id": "5b3b3d9c50b3772e6bbda9f8",
"display_name": "DangerCI",
"links": Object {
"avatar": Object {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128",
},
"html": Object {
"href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D",
},
},
"nickname": "DangerCI",
"type": "user",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
"self": Object {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106174425",
},
},
"pull_request": Object {
"pullrequest": Object {
"id": 324,
"links": Object {
"html": Object {
Expand All @@ -2614,6 +2564,26 @@ Generated by [Danger](https://danger.systems/ \\"generated_by_danger\\")
"title": "Test PR Title",
"type": "pullrequest",
},
"type": "pullrequest_comment",
"updated_on": "2019-06-18T18:23:19.636448+00:00",
"user": Object {
"account_id": "5b3b3d9c50b3772e6bbda9f8",
"display_name": "DangerCI",
"links": Object {
"avatar": Object {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128",
},
"html": Object {
"href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/",
},
"self": Object {
"href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D",
},
},
"nickname": "DangerCI",
"type": "user",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
},
},
]
`;
148 changes: 63 additions & 85 deletions source/platforms/_tests/fixtures/bitbucket_cloud_comments.json
Original file line number Diff line number Diff line change
@@ -1,109 +1,87 @@
[
{
"comment": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106400843"
},
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106400843" }
},
"deleted": false,
"pullrequest": {
"type": "pullrequest",
"id": 324,
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324" },
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324" }
},
"title": "Test PR Title"
},
"content": {
"raw": "⚠️ 1 Warning. Don't worry, everything is fixable.\n\n| | 1 Warning |\n|---|---|\n| ⚠️ | Couldn't find any related issue |\n\n| | 1 Message |\n|---|---|\n| ✨ | Rerun Danger https://bitbucket.org/foo/bar/addon/pipelines/home#!/results/1007 |\n\n\n\nGenerated by [Danger](https://danger.systems/ \"generated_by_danger\")\n",
"markup": "markdown",
"html": "<p>⚠️ 1 Warning. Don't worry, everything is fixable.</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>1 Warning</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>⚠️</td>\n<td>Couldn't find any related issue</td>\n</tr>\n</tbody>\n</table>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>1 Message</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>✨</td>\n<td>Rerun Danger <a href=\"https://bitbucket.org/foo/bar/addon/pipelines/home#!/results/1007\" rel=\"nofollow\" class=\"ap-connect-link\">https://bitbucket.org/foo/bar/addon/pipelines/home#!/results/1007</a></td>\n</tr>\n</tbody>\n</table>\n<p>Generated by <a data-is-external-link=\"true\" href=\"https://danger.systems/\" rel=\"nofollow\" title=\"generated_by_danger\">Danger</a></p>",
"type": "rendered"
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106400843"
},
"created_on": "2019-06-20T04:53:23.618489+00:00",
"user": {
"display_name": "DangerCI",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D" },
"html": { "href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/" },
"avatar": {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128"
}
},
"nickname": "DangerCI",
"type": "user",
"account_id": "5b3b3d9c50b3772e6bbda9f8"
},
"updated_on": "2019-06-20T04:53:23.680568+00:00",
"type": "pullrequest_comment",
"id": 106400843
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106400843" }
},
"pull_request": {
"deleted": false,
"pullrequest": {
"type": "pullrequest",
"id": 324,
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324" },
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324" }
},
"title": "Test PR Title"
}
},
{
"comment": {
},
"content": {
"raw": "⚠️ 1 Warning. Don't worry, everything is fixable.\n\n| | 1 Warning |\n|---|---|\n| ⚠️ | Couldn't find any related issue |\n\n| | 1 Message |\n|---|---|\n| ✨ | Rerun Danger https://bitbucket.org/foo/bar/addon/pipelines/home#!/results/1007 |\n\n\n\nGenerated by [Danger](https://danger.systems/ \"generated_by_danger\")\n",
"markup": "markdown",
"html": "<p>⚠️ 1 Warning. Don't worry, everything is fixable.</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>1 Warning</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>⚠️</td>\n<td>Couldn't find any related issue</td>\n</tr>\n</tbody>\n</table>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>1 Message</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>✨</td>\n<td>Rerun Danger <a href=\"https://bitbucket.org/foo/bar/addon/pipelines/home#!/results/1007\" rel=\"nofollow\" class=\"ap-connect-link\">https://bitbucket.org/foo/bar/addon/pipelines/home#!/results/1007</a></td>\n</tr>\n</tbody>\n</table>\n<p>Generated by <a data-is-external-link=\"true\" href=\"https://danger.systems/\" rel=\"nofollow\" title=\"generated_by_danger\">Danger</a></p>",
"type": "rendered"
},
"created_on": "2019-06-20T04:53:23.618489+00:00",
"user": {
"display_name": "DangerCI",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106174425"
},
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106174425" }
},
"deleted": false,
"pullrequest": {
"type": "pullrequest",
"id": 324,
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324" },
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324" }
},
"title": "Test PR Title"
"self": { "href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D" },
"html": { "href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/" },
"avatar": {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128"
}
},
"content": {
"raw": "remove this file",
"markup": "markdown",
"html": "<p>remove this file</p>",
"type": "rendered"
},
"created_on": "2019-06-18T18:23:19.626793+00:00",
"user": {
"display_name": "DangerCI",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D" },
"html": { "href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/" },
"avatar": {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128"
}
},
"nickname": "DangerCI",
"type": "user",
"account_id": "5b3b3d9c50b3772e6bbda9f8"
"nickname": "DangerCI",
"type": "user",
"account_id": "5b3b3d9c50b3772e6bbda9f8"
},
"updated_on": "2019-06-20T04:53:23.680568+00:00",
"type": "pullrequest_comment",
"id": 106400843
},
{
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324/comments/106174425"
},
"inline": {},
"updated_on": "2019-06-18T18:23:19.636448+00:00",
"type": "pullrequest_comment",
"id": 106174425
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324/_/diff#comment-106174425" }
},
"pull_request": {
"deleted": false,
"pullrequest": {
"type": "pullrequest",
"id": 324,
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/repositories/foo/bar/pullrequests/324" },
"html": { "href": "https://bitbucket.org/foo/bar/pull-requests/324" }
},
"title": "Test PR Title"
}
},
"content": {
"raw": "remove this file",
"markup": "markdown",
"html": "<p>remove this file</p>",
"type": "rendered"
},
"created_on": "2019-06-18T18:23:19.626793+00:00",
"user": {
"display_name": "DangerCI",
"uuid": "{b582acac-f2c2-47a8-a29b-e4c01c5274ab}",
"links": {
"self": { "href": "https://api.bitbucket.org/2.0/users/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D" },
"html": { "href": "https://bitbucket.org/%7Bb582acac-f2c2-47a8-a29b-e4c01c5274ab%7D/" },
"avatar": {
"href": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5b3b3d9c50b3772e6bbda9f8/1a7a3e0f-84d7-4948-b107-77b744b4d1c6/128"
}
},
"nickname": "DangerCI",
"type": "user",
"account_id": "5b3b3d9c50b3772e6bbda9f8"
},
"inline": {},
"updated_on": "2019-06-18T18:23:19.636448+00:00",
"type": "pullrequest_comment",
"id": 106174425
}
]

0 comments on commit ce1f631

Please sign in to comment.