Skip to content

Commit

Permalink
Merge branch 'main' into i4k-send-gitlab-user-id
Browse files Browse the repository at this point in the history
  • Loading branch information
i4ki authored Dec 20, 2024
2 parents f972c68 + d277299 commit 27e3605
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
14 changes: 12 additions & 2 deletions cmd/terramate/cli/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,8 @@ func (c *cli) newBitbucketReviewRequest(pr *bitbucket.PR) *cloud.ReviewRequest {
UpdatedAt: &updatedAt,
Status: pr.State,
Author: cloud.Author{
Login: pr.Author.DisplayName,
ID: pr.Author.UUID,
Login: pr.Author.DisplayName,
AvatarURL: avatarURL,
},
Branch: c.cloud.run.metadata.BitbucketPipelinesBranch,
Expand Down Expand Up @@ -1386,6 +1386,7 @@ func (c *cli) newGithubReviewRequest(
) *cloud.ReviewRequest {
author := cloud.Author{}
if user := pull.GetUser(); user != nil {
author.ID = strconv.Itoa64(int64(user.GetID()))
author.Login = user.GetLogin()
author.AvatarURL = user.GetAvatarURL()
}
Expand Down Expand Up @@ -1436,14 +1437,19 @@ func (c *cli) newGithubReviewRequest(
rr.ApprovedCount++
}

login := review.GetUser().GetLogin()
user := review.GetUser()
if user == nil {
continue
}

login := user.GetLogin()
if _, found := uniqueReviewers[login]; found {
continue
}
uniqueReviewers[login] = struct{}{}

rr.Reviewers = append(rr.Reviewers, cloud.Reviewer{
ID: strconv.Itoa64(user.GetID()),
Login: login,
AvatarURL: review.GetUser().GetAvatarURL(),
})
Expand Down Expand Up @@ -1489,6 +1495,7 @@ func (c *cli) newGitlabReviewRequest(mr gitlab.MR) *cloud.ReviewRequest {
UpdatedAt: &mrUpdatedAt,
Status: mr.State,
Author: cloud.Author{
ID: strconv.Itoa64(int64(mr.Author.ID)),
Login: mr.Author.Username,
AvatarURL: mr.Author.AvatarURL,
},
Expand All @@ -1502,6 +1509,9 @@ func (c *cli) newGitlabReviewRequest(mr gitlab.MR) *cloud.ReviewRequest {
Name: l,
})
}

// TODO(i4k): implement reviewers for Gitlab

return rr
}

Expand Down
20 changes: 13 additions & 7 deletions e2etests/cloud/run_cloud_sync_preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down Expand Up @@ -254,6 +255,7 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down Expand Up @@ -316,13 +318,17 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
Description: "Please pull these awesome changes in!",
URL: "https://github.com/octocat/Hello-World/pull/1347",
Labels: []cloud.Label{{Name: "bug", Color: "f29513", Description: "Something isn't working"}},
Author: cloud.Author{Login: "octocat", AvatarURL: "https://github.com/images/error/octocat_happy.gif"},
Status: "open",
CreatedAt: createdAt,
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Branch: "new-topic",
BaseBranch: "master",
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Status: "open",
CreatedAt: createdAt,
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Branch: "new-topic",
BaseBranch: "master",
},
StackPreviews: []*cloudstore.StackPreview{
{
Expand Down
2 changes: 2 additions & 0 deletions e2etests/cloud/run_script_cloud_preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func TestScriptRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down Expand Up @@ -295,6 +296,7 @@ func TestScriptRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down

0 comments on commit 27e3605

Please sign in to comment.