Skip to content

Commit d277299

Browse files
authored
chore: send author ids also for github and gitlab. (#2020)
## What this PR does / why we need it: Note: The sync of reviewers is still not sent for gitlab. ## Which issue(s) this PR fixes: none ## Special notes for your reviewer: ## Does this PR introduce a user-facing change? ``` no ```
2 parents 218cc71 + 7e5a8cd commit d277299

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

cmd/terramate/cli/cloud.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@ func (c *cli) newBitbucketReviewRequest(pr *bitbucket.PR) *cloud.ReviewRequest {
11051105
UpdatedAt: &updatedAt,
11061106
Status: pr.State,
11071107
Author: cloud.Author{
1108-
Login: pr.Author.DisplayName,
11091108
ID: pr.Author.UUID,
1109+
Login: pr.Author.DisplayName,
11101110
AvatarURL: avatarURL,
11111111
},
11121112
Branch: c.cloud.run.metadata.BitbucketPipelinesBranch,
@@ -1384,6 +1384,7 @@ func (c *cli) newGithubReviewRequest(
13841384
) *cloud.ReviewRequest {
13851385
author := cloud.Author{}
13861386
if user := pull.GetUser(); user != nil {
1387+
author.ID = strconv.Itoa64(int64(user.GetID()))
13871388
author.Login = user.GetLogin()
13881389
author.AvatarURL = user.GetAvatarURL()
13891390
}
@@ -1434,14 +1435,19 @@ func (c *cli) newGithubReviewRequest(
14341435
rr.ApprovedCount++
14351436
}
14361437

1437-
login := review.GetUser().GetLogin()
1438+
user := review.GetUser()
1439+
if user == nil {
1440+
continue
1441+
}
14381442

1443+
login := user.GetLogin()
14391444
if _, found := uniqueReviewers[login]; found {
14401445
continue
14411446
}
14421447
uniqueReviewers[login] = struct{}{}
14431448

14441449
rr.Reviewers = append(rr.Reviewers, cloud.Reviewer{
1450+
ID: strconv.Itoa64(user.GetID()),
14451451
Login: login,
14461452
AvatarURL: review.GetUser().GetAvatarURL(),
14471453
})
@@ -1487,6 +1493,7 @@ func (c *cli) newGitlabReviewRequest(mr gitlab.MR) *cloud.ReviewRequest {
14871493
UpdatedAt: &mrUpdatedAt,
14881494
Status: mr.State,
14891495
Author: cloud.Author{
1496+
ID: strconv.Itoa64(int64(mr.Author.ID)),
14901497
Login: mr.Author.Username,
14911498
AvatarURL: mr.Author.AvatarURL,
14921499
},
@@ -1500,6 +1507,9 @@ func (c *cli) newGitlabReviewRequest(mr gitlab.MR) *cloud.ReviewRequest {
15001507
Name: l,
15011508
})
15021509
}
1510+
1511+
// TODO(i4k): implement reviewers for Gitlab
1512+
15031513
return rr
15041514
}
15051515

e2etests/cloud/run_cloud_sync_preview_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
157157
UpdatedAt: updatedAt,
158158
PushedAt: &pushedAt,
159159
Author: cloud.Author{
160+
ID: "1",
160161
Login: "octocat",
161162
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
162163
},
@@ -254,6 +255,7 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
254255
UpdatedAt: updatedAt,
255256
PushedAt: &pushedAt,
256257
Author: cloud.Author{
258+
ID: "1",
257259
Login: "octocat",
258260
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
259261
},
@@ -316,13 +318,17 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
316318
Description: "Please pull these awesome changes in!",
317319
URL: "https://github.com/octocat/Hello-World/pull/1347",
318320
Labels: []cloud.Label{{Name: "bug", Color: "f29513", Description: "Something isn't working"}},
319-
Author: cloud.Author{Login: "octocat", AvatarURL: "https://github.com/images/error/octocat_happy.gif"},
320-
Status: "open",
321-
CreatedAt: createdAt,
322-
UpdatedAt: updatedAt,
323-
PushedAt: &pushedAt,
324-
Branch: "new-topic",
325-
BaseBranch: "master",
321+
Author: cloud.Author{
322+
ID: "1",
323+
Login: "octocat",
324+
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
325+
},
326+
Status: "open",
327+
CreatedAt: createdAt,
328+
UpdatedAt: updatedAt,
329+
PushedAt: &pushedAt,
330+
Branch: "new-topic",
331+
BaseBranch: "master",
326332
},
327333
StackPreviews: []*cloudstore.StackPreview{
328334
{

e2etests/cloud/run_script_cloud_preview_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func TestScriptRunWithCloudSyncPreview(t *testing.T) {
189189
UpdatedAt: updatedAt,
190190
PushedAt: &pushedAt,
191191
Author: cloud.Author{
192+
ID: "1",
192193
Login: "octocat",
193194
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
194195
},
@@ -295,6 +296,7 @@ func TestScriptRunWithCloudSyncPreview(t *testing.T) {
295296
UpdatedAt: updatedAt,
296297
PushedAt: &pushedAt,
297298
Author: cloud.Author{
299+
ID: "1",
298300
Login: "octocat",
299301
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
300302
},

0 commit comments

Comments
 (0)