Skip to content

Commit

Permalink
fix: Bitbucket Cloud PR Author is processed correctly (#20769) (#20990)…
Browse files Browse the repository at this point in the history
… (#21039)

Fixes #20769

Author there is a struct, not a string. Use nickname from that struct as an author name.

Let's cherry pick to 2.11-2.13

Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
Co-authored-by: Andrii Korotkov <137232734+andrii-korotkov-verkada@users.noreply.github.com>
  • Loading branch information
1 parent 831e452 commit 89ef356
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
9 changes: 7 additions & 2 deletions applicationset/services/pull_request/bitbucket_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type BitbucketCloudPullRequest struct {
ID int `json:"id"`
Title string `json:"title"`
Source BitbucketCloudPullRequestSource `json:"source"`
Author string `json:"author"`
Author BitbucketCloudPullRequestAuthor `json:"author"`
}

type BitbucketCloudPullRequestSource struct {
Expand All @@ -35,6 +35,11 @@ type BitbucketCloudPullRequestSourceCommit struct {
Hash string `json:"hash"`
}

// Also have display_name and uuid, but don't plan to use them.
type BitbucketCloudPullRequestAuthor struct {
Nickname string `json:"nickname"`
}

type PullRequestResponse struct {
Page int32 `json:"page"`
Size int32 `json:"size"`
Expand Down Expand Up @@ -134,7 +139,7 @@ func (b *BitbucketCloudService) List(_ context.Context) ([]*PullRequest, error)
Title: pull.Title,
Branch: pull.Source.Branch.Name,
HeadSHA: pull.Source.Commit.Hash,
Author: pull.Author,
Author: pull.Author.Nickname,
})
}

Expand Down
28 changes: 21 additions & 7 deletions applicationset/services/pull_request/bitbucket_cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func defaultHandlerCloud(t *testing.T) func(http.ResponseWriter, *http.Request)
"hash": "1a8dd249c04a"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
}
]
}`)
Expand Down Expand Up @@ -154,7 +156,9 @@ func TestListPullRequestPaginationCloud(t *testing.T) {
"hash": "1a8dd249c04a"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
},
{
"id": 102,
Expand All @@ -168,7 +172,9 @@ func TestListPullRequestPaginationCloud(t *testing.T) {
"hash": "4cf807e67a6d"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
}
]
}`, r.Host))
Expand All @@ -191,7 +197,9 @@ func TestListPullRequestPaginationCloud(t *testing.T) {
"hash": "6344d9623e3b"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
}
]
}`, r.Host))
Expand Down Expand Up @@ -339,7 +347,9 @@ func TestListPullRequestBranchMatchCloud(t *testing.T) {
"hash": "1a8dd249c04a"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
},
{
"id": 200,
Expand All @@ -353,7 +363,9 @@ func TestListPullRequestBranchMatchCloud(t *testing.T) {
"hash": "4cf807e67a6d"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
}
]
}`, r.Host))
Expand All @@ -376,7 +388,9 @@ func TestListPullRequestBranchMatchCloud(t *testing.T) {
"hash": "6344d9623e3b"
}
},
"author": "testName"
"author": {
"nickname": "testName"
}
}
]
}`, r.Host))
Expand Down

0 comments on commit 89ef356

Please sign in to comment.