Skip to content

Commit

Permalink
fix(bitbucketcloud)!: Use AccountID as username instead of Nickname (#…
Browse files Browse the repository at this point in the history
…2034)

* fix(bitbucketcloud)!: Use AccountID as username instead of Nickname

* Update PullRequest.Author as well

* Remove unused Nickname field
  • Loading branch information
maxbrunet authored Mar 7, 2022
1 parent 8981185 commit 24e8cf7
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 30 deletions.
4 changes: 2 additions & 2 deletions server/events/event_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ func (e *EventParser) parseCommonBitbucketCloudEventData(event bitbucketcloud.Co
URL: *event.PullRequest.Links.HTML.HREF,
HeadBranch: *event.PullRequest.Source.Branch.Name,
BaseBranch: *event.PullRequest.Destination.Branch.Name,
Author: *event.Actor.Nickname,
Author: *event.Actor.AccountID,
State: prState,
BaseRepo: baseRepo,
}
user = models.User{
Username: *event.Actor.Nickname,
Username: *event.Actor.AccountID,
}
return
}
Expand Down
8 changes: 4 additions & 4 deletions server/events/event_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ func TestParseBitbucketCloudCommentEvent_ValidEvent(t *testing.T) {
URL: "https://bitbucket.org/lkysow/atlantis-example/pull-requests/2",
HeadBranch: "lkysow/maintf-edited-online-with-bitbucket-1532029690581",
BaseBranch: "master",
Author: "lkysow",
Author: "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
State: models.ClosedPullState,
BaseRepo: expBaseRepo,
}, pull)
Expand All @@ -785,7 +785,7 @@ func TestParseBitbucketCloudCommentEvent_ValidEvent(t *testing.T) {
},
}, headRepo)
Equals(t, models.User{
Username: "lkysow",
Username: "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
}, user)
Equals(t, "my comment", comment)
}
Expand Down Expand Up @@ -855,7 +855,7 @@ func TestParseBitbucketCloudPullEvent_ValidEvent(t *testing.T) {
URL: "https://bitbucket.org/lkysow/atlantis-example/pull-requests/16",
HeadBranch: "Luke/maintf-edited-online-with-bitbucket-1560433073473",
BaseBranch: "master",
Author: "Luke",
Author: "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
State: models.OpenPullState,
BaseRepo: expBaseRepo,
}, pull)
Expand All @@ -871,7 +871,7 @@ func TestParseBitbucketCloudPullEvent_ValidEvent(t *testing.T) {
},
}, headRepo)
Equals(t, models.User{
Username: "Luke",
Username: "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
}, user)
}

Expand Down
6 changes: 0 additions & 6 deletions server/events/testdata/bitbucket-cloud-comment-event.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"created_on": "2018-07-19T19:51:50.607374+00:00",
"user": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand Down Expand Up @@ -159,7 +158,6 @@
},
"state": "MERGED",
"author": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand All @@ -181,7 +179,6 @@
{
"type": "participant",
"user": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand Down Expand Up @@ -214,7 +211,6 @@
}
},
"closed_by": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand All @@ -234,7 +230,6 @@
"task_count": 0
},
"actor": {
"username": "lkysow",
"nickname": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
Expand Down Expand Up @@ -269,7 +264,6 @@
},
"full_name": "lkysow/atlantis-example",
"owner": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
},
"state": "OPEN",
"author": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand All @@ -129,7 +128,6 @@
{
"type": "participant",
"user": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand Down Expand Up @@ -158,7 +156,6 @@
"task_count": 0
},
"actor": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand Down Expand Up @@ -192,7 +189,6 @@
},
"full_name": "lkysow/atlantis-example",
"owner": {
"username": "lkysow",
"display_name": "Luke",
"account_id": "557058:dc3817de-68b5-45cd-b81c-5c39d2560090",
"links": {
Expand Down
2 changes: 1 addition & 1 deletion server/events/vcs/bitbucketcloud/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type DiffStatFile struct {
}

type Actor struct {
Nickname *string `json:"nickname,omitempty" validate:"required"`
AccountID *string `json:"account_id,omitempty" validate:"required"`
}
type Repository struct {
FullName *string `json:"full_name,omitempty" validate:"required"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"type": "participant",
"approved": true,
"user": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand All @@ -161,7 +160,6 @@
"type": "participant",
"approved": false,
"user": {
"username": "atlantis-bot",
"display_name": "Atlantisbot",
"uuid": "{73686412-4495-426f-89a7-c69ff1c8d7b8}",
"links": {
Expand All @@ -184,7 +182,6 @@
"reason": "",
"updated_on": "2019-06-03T13:55:54.081581+00:00",
"author": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"type": "participant",
"approved": false,
"user": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand All @@ -161,7 +160,6 @@
"type": "participant",
"approved": true,
"user": {
"username": "atlantis-bot",
"display_name": "Atlantisbot",
"uuid": "{73686412-4495-426f-89a7-c69ff1c8d7b8}",
"links": {
Expand All @@ -186,7 +184,6 @@
"type": "participant",
"approved": true,
"user": {
"username": "atlantis-bot2",
"display_name": "Atlantisbot2",
"uuid": "{73686412-4495-426f-89a7-c69ff1c8d7b2}",
"links": {
Expand All @@ -209,7 +206,6 @@
"reason": "",
"updated_on": "2019-06-03T13:55:17.639190+00:00",
"author": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand Down
3 changes: 0 additions & 3 deletions server/events/vcs/bitbucketcloud/testdata/pull-approved.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"type": "participant",
"approved": false,
"user": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand All @@ -161,7 +160,6 @@
"type": "participant",
"approved": true,
"user": {
"username": "atlantis-bot",
"display_name": "Atlantisbot",
"uuid": "{73686412-4495-426f-89a7-c69ff1c8d7b8}",
"links": {
Expand All @@ -184,7 +182,6 @@
"reason": "",
"updated_on": "2019-06-03T13:55:17.639190+00:00",
"author": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"type": "participant",
"approved": false,
"user": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand All @@ -161,7 +160,6 @@
"type": "participant",
"approved": false,
"user": {
"username": "atlantis-bot",
"display_name": "Atlantisbot",
"uuid": "{73686412-4495-426f-89a7-c69ff1c8d7b8}",
"links": {
Expand All @@ -184,7 +182,6 @@
"reason": "",
"updated_on": "2019-06-03T13:54:09.266101+00:00",
"author": {
"username": "lkysow",
"display_name": "Luke",
"uuid": "{bf34a99b-8a11-452c-8fbc-bdffc340e584}",
"links": {
Expand Down

0 comments on commit 24e8cf7

Please sign in to comment.