Skip to content

Support parsing PR comment events for Bitbucket Cloud #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 331 additions & 0 deletions scm/driver/bitbucket/testdata/webhooks/pr_comment_created.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
{
"comment": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/comments/311512047"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1/_/diff#comment-311512047"
}
},
"deleted": false,
"pullrequest": {
"type": "pullrequest",
"id": 1,
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1"
}
},
"title": "Update pom.xml"
},
"content": {
"raw": "test comment",
"markup": "markdown",
"html": "<p>test comment</p>",
"type": "rendered"
},
"created_on": "2022-06-23T22:10:09.939925+00:00",
"user": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"updated_on": "2022-06-23T22:10:09.939978+00:00",
"type": "pullrequest_comment",
"id": 311512047
},
"pullrequest": {
"rendered": {
"description": {
"raw": "Test",
"markup": "markdown",
"html": "<p>Test</p>",
"type": "rendered"
},
"title": {
"raw": "Update pom.xml",
"markup": "markdown",
"html": "<p>Update pom.xml</p>",
"type": "rendered"
}
},
"type": "pullrequest",
"description": "Test",
"links": {
"decline": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/decline"
},
"diffstat": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/diffstat/rutvijmehta-harness/spring-cloud-alibaba:b9437f32dddd%0Dcfd2d864e389?from_pullrequest_id=1&topic=true"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/commits"
},
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1"
},
"comments": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/comments"
},
"merge": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/merge"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1"
},
"activity": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/activity"
},
"request-changes": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/request-changes"
},
"diff": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/diff/rutvijmehta-harness/spring-cloud-alibaba:b9437f32dddd%0Dcfd2d864e389?from_pullrequest_id=1&topic=true"
},
"approve": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/approve"
},
"statuses": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/statuses"
}
},
"title": "Update pom.xml",
"close_source_branch": false,
"reviewers": [],
"id": 1,
"destination": {
"commit": {
"hash": "cfd2d864e389",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/commit/cfd2d864e389"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/commits/cfd2d864e389"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B4402cbae-7790-453a-b29e-5fcab61a84df%7D?ts=default"
}
},
"type": "repository",
"name": "spring-cloud-alibaba",
"full_name": "rutvijmehta-harness/spring-cloud-alibaba",
"uuid": "{4402cbae-7790-453a-b29e-5fcab61a84df}"
},
"branch": {
"name": "2021.x"
}
},
"created_on": "2022-06-23T19:27:25.443049+00:00",
"summary": {
"raw": "Test",
"markup": "markdown",
"html": "<p>Test</p>",
"type": "rendered"
},
"source": {
"commit": {
"hash": "b9437f32dddd",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/commit/b9437f32dddd"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/commits/b9437f32dddd"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B4402cbae-7790-453a-b29e-5fcab61a84df%7D?ts=default"
}
},
"type": "repository",
"name": "spring-cloud-alibaba",
"full_name": "rutvijmehta-harness/spring-cloud-alibaba",
"uuid": "{4402cbae-7790-453a-b29e-5fcab61a84df}"
},
"branch": {
"name": "tiwhitepaper-rutvij"
}
},
"comment_count": 1,
"state": "OPEN",
"task_count": 0,
"participants": [
{
"participated_on": "2022-06-23T22:10:09.939978+00:00",
"state": null,
"role": "PARTICIPANT",
"user": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"type": "participant",
"approved": false
}
],
"reason": "",
"updated_on": "2022-06-23T22:10:09.939978+00:00",
"author": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"merge_commit": null,
"closed_by": null
},
"repository": {
"scm": "git",
"website": null,
"uuid": "{4402cbae-7790-453a-b29e-5fcab61a84df}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B4402cbae-7790-453a-b29e-5fcab61a84df%7D?ts=default"
}
},
"project": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/rutvijmehta-harness/projects/TEST"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/workspace/projects/TEST"
},
"avatar": {
"href": "https://bitbucket.org/account/user/rutvijmehta-harness/projects/TEST/avatar/32?ts=1655023274"
}
},
"type": "project",
"name": "Test",
"key": "TEST",
"uuid": "{aa857cae-daad-4fbd-93ef-503cc3d6c3d6}"
},
"full_name": "rutvijmehta-harness/spring-cloud-alibaba",
"owner": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"workspace": {
"slug": "rutvijmehta-harness",
"type": "workspace",
"name": "Rutvij Mehta",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/rutvijmehta-harness"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/"
},
"avatar": {
"href": "https://bitbucket.org/workspaces/rutvijmehta-harness/avatar/?ts=1655023237"
}
},
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}"
},
"type": "repository",
"is_private": false,
"name": "spring-cloud-alibaba"
},
"actor": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"Action": "created",
"Repo": {
"ID": "{4402cbae-7790-453a-b29e-5fcab61a84df}",
"Namespace": "rutvijmehta-harness",
"Name": "spring-cloud-alibaba",
"Perm": null,
"Branch": "",
"Archived": false,
"Private": false,
"Visibility": 0,
"Clone": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba.git",
"CloneSSH": "git@bitbucket.org:rutvijmehta-harness/spring-cloud-alibaba.git",
"Link": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Issue": {
"Number": 1,
"Title": "Update pom.xml",
"Body": "Test",
"Link": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1",
"Labels": null,
"Closed": false,
"Locked": false,
"Author": {
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"PullRequest": {
"Number": 1,
"Title": "Update pom.xml",
"Body": "Test",
"Sha": "b9437f32dddd",
"Ref": "refs/pull-requests/1/from",
"Source": "tiwhitepaper-rutvij",
"Target": "2021.x",
"Fork": "rutvijmehta-harness/spring-cloud-alibaba",
"Link": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1",
"Diff": "",
"Closed": false,
"Merged": false,
"Base": {
"Name": "",
"Path": "",
"Sha": ""
},
"Head": {
"Name": "",
"Path": "",
"Sha": ""
},
"Author": {
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Created": "2022-06-23T19:27:25.443049Z",
"Updated": "2022-06-23T22:10:09.939978Z",
"Labels": null
},
"Created": "2022-06-23T19:27:25.443049Z",
"Updated": "2022-06-23T22:10:09.939978Z"
},
"Comment": {
"ID": 311512047,
"Body": "test comment",
"Author": {
"ID": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Created": "2022-06-23T22:10:09.939925Z",
"Updated": "2022-06-23T22:10:09.939978Z"
},
"Sender": {
"ID": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
}
}
305 changes: 305 additions & 0 deletions scm/driver/bitbucket/testdata/webhooks/pr_comment_deleted.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
{
"comment": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/comments/311512047"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1/_/diff#comment-311512047"
}
},
"deleted": true,
"pullrequest": {
"type": "pullrequest",
"id": 1,
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1"
}
},
"title": "Update pom.xml"
},
"content": {
"raw": "",
"markup": "markdown",
"html": "",
"type": "rendered"
},
"created_on": "2022-06-23T22:10:09.939925+00:00",
"user": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"updated_on": "2022-06-24T01:38:47.831843+00:00",
"type": "pullrequest_comment",
"id": 311512047
},
"pullrequest": {
"rendered": {
"description": {
"raw": "Test",
"markup": "markdown",
"html": "<p>Test</p>",
"type": "rendered"
},
"title": {
"raw": "Update pom.xml",
"markup": "markdown",
"html": "<p>Update pom.xml</p>",
"type": "rendered"
}
},
"type": "pullrequest",
"description": "Test",
"links": {
"decline": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/decline"
},
"diffstat": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/diffstat/rutvijmehta-harness/spring-cloud-alibaba:b9437f32dddd%0Dcfd2d864e389?from_pullrequest_id=1&topic=true"
},
"commits": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/commits"
},
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1"
},
"comments": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/comments"
},
"merge": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/merge"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1"
},
"activity": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/activity"
},
"request-changes": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/request-changes"
},
"diff": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/diff/rutvijmehta-harness/spring-cloud-alibaba:b9437f32dddd%0Dcfd2d864e389?from_pullrequest_id=1&topic=true"
},
"approve": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/approve"
},
"statuses": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/pullrequests/1/statuses"
}
},
"title": "Update pom.xml",
"close_source_branch": false,
"reviewers": [],
"id": 1,
"destination": {
"commit": {
"hash": "cfd2d864e389",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/commit/cfd2d864e389"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/commits/cfd2d864e389"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B4402cbae-7790-453a-b29e-5fcab61a84df%7D?ts=default"
}
},
"type": "repository",
"name": "spring-cloud-alibaba",
"full_name": "rutvijmehta-harness/spring-cloud-alibaba",
"uuid": "{4402cbae-7790-453a-b29e-5fcab61a84df}"
},
"branch": {
"name": "2021.x"
}
},
"created_on": "2022-06-23T19:27:25.443049+00:00",
"summary": {
"raw": "Test",
"markup": "markdown",
"html": "<p>Test</p>",
"type": "rendered"
},
"source": {
"commit": {
"hash": "b9437f32dddd",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba/commit/b9437f32dddd"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/commits/b9437f32dddd"
}
}
},
"repository": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B4402cbae-7790-453a-b29e-5fcab61a84df%7D?ts=default"
}
},
"type": "repository",
"name": "spring-cloud-alibaba",
"full_name": "rutvijmehta-harness/spring-cloud-alibaba",
"uuid": "{4402cbae-7790-453a-b29e-5fcab61a84df}"
},
"branch": {
"name": "tiwhitepaper-rutvij"
}
},
"comment_count": 0,
"state": "OPEN",
"task_count": 0,
"participants": [],
"reason": "",
"updated_on": "2022-06-24T01:40:18.667126+00:00",
"author": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"merge_commit": null,
"closed_by": null
},
"repository": {
"scm": "git",
"website": null,
"uuid": "{4402cbae-7790-453a-b29e-5fcab61a84df}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/rutvijmehta-harness/spring-cloud-alibaba"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba"
},
"avatar": {
"href": "https://bytebucket.org/ravatar/%7B4402cbae-7790-453a-b29e-5fcab61a84df%7D?ts=default"
}
},
"project": {
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/rutvijmehta-harness/projects/TEST"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/workspace/projects/TEST"
},
"avatar": {
"href": "https://bitbucket.org/account/user/rutvijmehta-harness/projects/TEST/avatar/32?ts=1655023274"
}
},
"type": "project",
"name": "Test",
"key": "TEST",
"uuid": "{aa857cae-daad-4fbd-93ef-503cc3d6c3d6}"
},
"full_name": "rutvijmehta-harness/spring-cloud-alibaba",
"owner": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
},
"workspace": {
"slug": "rutvijmehta-harness",
"type": "workspace",
"name": "Rutvij Mehta",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/workspaces/rutvijmehta-harness"
},
"html": {
"href": "https://bitbucket.org/rutvijmehta-harness/"
},
"avatar": {
"href": "https://bitbucket.org/workspaces/rutvijmehta-harness/avatar/?ts=1655023237"
}
},
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}"
},
"type": "repository",
"is_private": false,
"name": "spring-cloud-alibaba"
},
"actor": {
"display_name": "Rutvij Mehta",
"uuid": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D"
},
"html": {
"href": "https://bitbucket.org/%7B145a94da-035e-42d6-bf85-296cea8005ba%7D/"
},
"avatar": {
"href": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png"
}
},
"type": "user",
"nickname": "Rutvij Mehta",
"account_id": "624de6f6fd5e450070486936"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"Action": "deleted",
"Repo": {
"ID": "{4402cbae-7790-453a-b29e-5fcab61a84df}",
"Namespace": "rutvijmehta-harness",
"Name": "spring-cloud-alibaba",
"Perm": null,
"Branch": "",
"Archived": false,
"Private": false,
"Visibility": 0,
"Clone": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba.git",
"CloneSSH": "git@bitbucket.org:rutvijmehta-harness/spring-cloud-alibaba.git",
"Link": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Issue": {
"Number": 1,
"Title": "Update pom.xml",
"Body": "Test",
"Link": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1",
"Labels": null,
"Closed": false,
"Locked": false,
"Author": {
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"PullRequest": {
"Number": 1,
"Title": "Update pom.xml",
"Body": "Test",
"Sha": "b9437f32dddd",
"Ref": "refs/pull-requests/1/from",
"Source": "tiwhitepaper-rutvij",
"Target": "2021.x",
"Fork": "rutvijmehta-harness/spring-cloud-alibaba",
"Link": "https://bitbucket.org/rutvijmehta-harness/spring-cloud-alibaba/pull-requests/1",
"Diff": "",
"Closed": false,
"Merged": false,
"Base": {
"Name": "",
"Path": "",
"Sha": ""
},
"Head": {
"Name": "",
"Path": "",
"Sha": ""
},
"Author": {
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Created": "2022-06-23T19:27:25.443049Z",
"Updated": "2022-06-24T01:40:18.667126Z",
"Labels": null
},
"Created": "2022-06-23T19:27:25.443049Z",
"Updated": "2022-06-24T01:40:18.667126Z"
},
"Comment": {
"ID": 311512047,
"Body": "",
"Author": {
"ID": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"Created": "2022-06-23T22:10:09.939925Z",
"Updated": "2022-06-24T01:38:47.831843Z"
},
"Sender": {
"ID": "{145a94da-035e-42d6-bf85-296cea8005ba}",
"Login": "",
"Name": "Rutvij Mehta",
"Email": "",
"Avatar": "https://secure.gravatar.com/avatar/1bf4d1258f18330b314d2737db430cb0?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FRM-5.png",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
}
}
279 changes: 279 additions & 0 deletions scm/driver/bitbucket/webhook.go
Original file line number Diff line number Diff line change
@@ -53,6 +53,23 @@ func (s *webhookService) Parse(req *http.Request, fn scm.SecretFunc) (scm.Webhoo
if hook != nil {
hook.(*scm.PullRequestHook).Action = scm.ActionClose
}
case "pullrequest:comment_created":
hook, err = s.parsePullRequestCommentHook(data)
if hook != nil {
hook.(*scm.IssueCommentHook).Action = scm.ActionCreate
}
case "pullrequest:comment_updated":
// Bitbucket PR Comment Update is unreliable and does not send events
// most of the time https://github.com/iterative/cml/issues/817
hook, err = s.parsePullRequestCommentHook(data)
if hook != nil {
hook.(*scm.IssueCommentHook).Action = scm.ActionEdit
}
case "pullrequest:comment_deleted":
hook, err = s.parsePullRequestCommentHook(data)
if hook != nil {
hook.(*scm.IssueCommentHook).Action = scm.ActionDelete
}
}
if err != nil {
return nil, err
@@ -78,6 +95,12 @@ func (s *webhookService) Parse(req *http.Request, fn scm.SecretFunc) (scm.Webhoo
return hook, nil
}

func (s *webhookService) parsePullRequestCommentHook(data []byte) (scm.Webhook, error) {
dst := new(prCommentHook)
err := json.Unmarshal(data, dst)
return convertPrCommentHook(dst), err
}

func (s *webhookService) parsePushHook(data []byte) (scm.Webhook, error) {
dst := new(pushHook)
err := json.Unmarshal(data, dst)
@@ -381,6 +404,194 @@ type (
} `json:"links"`
UUID string `json:"uuid"`
}

prComment struct {
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
} `json:"links"`
Deleted bool `json:"deleted"`
PullRequest struct {
Type string `json:"type"`
ID int `json:"id"`
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
} `json:"links"`
Title string `json:"title"`
}
Content struct {
Raw string `json:"raw"`
Markup string `json:"markup"`
Html string `json:"html"`
Type string `json:"type"`
}
CreatedOn time.Time `json:"created_on"`
User prCommentHookUser `json:"user"`
UpdatedOn time.Time `json:"updated_on"`
Type string `json:"type"`
ID int `json:"id"`
}

prCommentHookRepo struct {
Scm string `json:"scm"`
Website string `json:"website"`
UUID string `json:"uuid"`
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
Avatar link `json:"avatar"`
} `json:"links"`
Project struct {
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
Avatar link `json:"avatar"`
} `json:"links"`
Type string `json:"type"`
Name string `json:"name"`
Key string `json:"key"`
UUID string `json:"uuid"`
} `json:"project"`
FullName string `json:"full_name"`
Owner prCommentHookUser `json:"owner"`
Workspace struct {
Slug string `json:"slugg"`
Type string `json:"type"`
Name string `json:"name"`
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
Avatar link `json:"avatar"`
} `json:"links"`
UUID string `json:"uuid"`
} `json:"workspace"`
Type string `json:"type"`
IsPrivate bool `json:"is_private"`
Name string `json:"name"`
}

prCommentHookUser struct {
Username string `json:"username"`
DisplayName string `json:"display_name"`
UUID string `json:"uuid"`
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
Avatar link `json:"avatar"`
} `json:"links"`
Type string `json:"type"`
Nickname string `json:"nickname"`
AccountID string `json:"account_id"`
}

prCommentHookPullRequest struct {
Rendered struct {
Description struct {
Raw string `json:"raw"`
Markup string `json:"markup"`
Html string `json:"html"`
Type string `json:"type"`
} `json:"description"`
Title struct {
Raw string `json:"raw"`
Markup string `json:"markup"`
Html string `json:"html"`
Type string `json:"type"`
} `json:"title"`
} `json:"rendered"`
Type string `json:"type"`
Description string `json:"description"`
Links struct {
Decline link `json:"decline"`
Diffstat link `json:"diffstat"`
Commits link `json:"commits"`
Self link `json:"self"`
Comments link `json:"comments"`
Merge link `json:"merge"`
Html link `json:"html"`
Activity link `json:"activity"`
RequestChanges link `json:"request-changes"`
Diff link `json:"diff"`
Approve link `json:"approve"`
Statuses link `json:"statuses"`
} `json:"links"`
Title string `json:"title"`
CloseSourceBranch bool `json:"close_source_branch"`
Reviewers []interface{} `json:"reviewers"`
ID int `json:"id"`
Destination struct {
Commit struct {
Hash string `json:"hash"`
Type string `json:"type"`
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
} `json:"links"`
}
Repository struct {
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
Avatar link `json:"avatar"`
} `json:"links"`
Type string `json:"type"`
Name string `json:"name"`
FullName string `json:"full_name"`
UUID string `json:"uuid"`
} `json:"repository"`
Branch struct {
Name string `json:"name"`
} `json:"branch"`
} `json:"destination"`
CreatedOn time.Time `json:"created_on"`
Summary struct {
Raw string `json:"raw"`
Markup string `json:"markup"`
Html string `json:"html"`
Type string `json:"type"`
} `json:"summary"`
Source struct {
Commit struct {
Hash string `json:"hash"`
Type string `json:"type"`
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
} `json:"links"`
}
Repository struct {
Links struct {
Self link `json:"self"`
HTML link `json:"html"`
Avatar link `json:"avatar"`
} `json:"links"`
Type string `json:"type"`
Name string `json:"name"`
FullName string `json:"full_name"`
UUID string `json:"uuid"`
} `json:"repository"`
Branch struct {
Name string `json:"name"`
} `json:"branch"`
} `json:"source"`
CommentCount int `json:"comment_count"`
State string `json:"state"`
TaskCount int `json:"task_count"`
Participants []interface{} `json:"participants"`
Reason string `json:"reason"`
UpdatedOn time.Time `json:"updated_on"`
Author prCommentHookUser `json:"author"`
MergeCommit interface{} `json:"merge_commit"`
ClosedBy interface{} `json:"closed_by"`
}

prCommentHook struct {
Comment prComment `json:"comment"`
PullRequest prCommentHookPullRequest `json:"pullRequest"`
Repository prCommentHookRepo `json:"repository"`
Actor prCommentHookUser `json:"actor"`
}
)

//
@@ -610,3 +821,71 @@ func convertPullRequestHook(src *webhook) *scm.PullRequestHook {
},
}
}

func convertPrCommentHook(src *prCommentHook) *scm.IssueCommentHook {
namespace, _ := scm.Split(src.Repository.FullName)
dst := scm.IssueCommentHook{
Repo: scm.Repository{
ID: src.Repository.UUID,
Namespace: namespace,
Name: src.Repository.Name,
Clone: fmt.Sprintf("https://bitbucket.org/%s.git", src.Repository.FullName),
CloneSSH: fmt.Sprintf("git@bitbucket.org:%s.git", src.Repository.FullName),
Link: src.Repository.Links.HTML.Href,
Private: src.Repository.IsPrivate,
},
Issue: scm.Issue{
Number: src.PullRequest.ID,
Title: src.PullRequest.Title,
Body: src.PullRequest.Description,
Link: src.PullRequest.Links.Html.Href,
Author: scm.User{
Login: src.PullRequest.Author.Username,
Name: src.PullRequest.Author.DisplayName,
Avatar: src.PullRequest.Author.Links.Avatar.Href,
},
PullRequest: scm.PullRequest{
Number: src.PullRequest.ID,
Title: src.PullRequest.Title,
Body: src.PullRequest.Description,
Sha: src.PullRequest.Source.Commit.Hash,
// Bitbucket does not support PR Refs: https://jira.atlassian.com/browse/BCLOUD-5814
Ref: fmt.Sprintf("refs/pull-requests/%d/from", src.PullRequest.ID),
Source: src.PullRequest.Source.Branch.Name,
Target: src.PullRequest.Destination.Branch.Name,
Fork: src.PullRequest.Source.Repository.FullName,
Link: src.PullRequest.Links.Html.Href,
Closed: src.PullRequest.State != "OPEN",
Merged: src.PullRequest.State == "MERGED",
Author: scm.User{
Login: src.PullRequest.Author.Username,
Name: src.PullRequest.Author.DisplayName,
Avatar: src.PullRequest.Author.Links.Avatar.Href,
},
Created: src.PullRequest.CreatedOn,
Updated: src.PullRequest.UpdatedOn,
},
Created: src.PullRequest.CreatedOn,
Updated: src.PullRequest.UpdatedOn,
},
Comment: scm.Comment{
ID: src.Comment.ID,
Body: src.Comment.Content.Raw,
Author: scm.User{
ID: src.Comment.User.UUID,
Login: src.Comment.User.Username,
Name: src.Comment.User.DisplayName,
Avatar: src.Comment.User.Links.Avatar.Href,
},
Created: src.Comment.CreatedOn,
Updated: src.Comment.UpdatedOn,
},
Sender: scm.User{
ID: src.Actor.UUID,
Login: src.Actor.Username,
Name: src.Actor.DisplayName,
Avatar: src.Actor.Links.Avatar.Href,
},
}
return &dst
}
14 changes: 14 additions & 0 deletions scm/driver/bitbucket/webhook_test.go
Original file line number Diff line number Diff line change
@@ -132,6 +132,20 @@ func TestWebhooks(t *testing.T) {
// after: "samples/pr_unlabeled.json.golden",
// obj: new(scm.PullRequestHook),
// },
{
sig: "71295b197fa25f4356d2fb9965df3f2379d903d7",
event: "pullrequest:comment_created",
before: "testdata/webhooks/pr_comment_created.json",
after: "testdata/webhooks/pr_comment_created.json.golden",
obj: new(scm.IssueCommentHook),
},
{
sig: "71295b197fa25f4356d2fb9965df3f2379d903d7",
event: "pullrequest:comment_deleted",
before: "testdata/webhooks/pr_comment_deleted.json",
after: "testdata/webhooks/pr_comment_deleted.json.golden",
obj: new(scm.IssueCommentHook),
},
}

for _, test := range tests {
1 change: 1 addition & 0 deletions scm/user.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
type (
// User represents a user account.
User struct {
ID string
Login string
Name string
Email string