Skip to content

Commit 05a8875

Browse files
authored
Revert PR #1020 to undo performance regression as reported in #1328 (#1330)
This reverts commit 553785b.
1 parent ad2193c commit 05a8875

File tree

5 files changed

+49
-295
lines changed

5 files changed

+49
-295
lines changed

github/resource_github_branch_protection.go

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -154,27 +154,6 @@ func resourceGithubBranchProtectionCreate(d *schema.ResourceData, meta interface
154154
if err != nil {
155155
return err
156156
}
157-
158-
var reviewIds, pushIds, bypassIds []string
159-
reviewIds, err = getActorIds(data.ReviewDismissalActorIDs, meta)
160-
if err != nil {
161-
return err
162-
}
163-
164-
pushIds, err = getActorIds(data.PushActorIDs, meta)
165-
if err != nil {
166-
return err
167-
}
168-
169-
bypassIds, err = getActorIds(data.BypassPullRequestActorIDs, meta)
170-
if err != nil {
171-
return err
172-
}
173-
174-
data.PushActorIDs = pushIds
175-
data.ReviewDismissalActorIDs = reviewIds
176-
data.BypassPullRequestActorIDs = bypassIds
177-
178157
input := githubv4.CreateBranchProtectionRuleInput{
179158
AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)),
180159
AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)),
@@ -276,11 +255,7 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{}
276255
log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_CONVERSATION_RESOLUTION, protection.Repository.Name, protection.Pattern, d.Id())
277256
}
278257

279-
approvingReviews, err := setApprovingReviews(protection, d, meta)
280-
if err != nil {
281-
return err
282-
}
283-
258+
approvingReviews := setApprovingReviews(protection)
284259
err = d.Set(PROTECTION_REQUIRES_APPROVING_REVIEWS, approvingReviews)
285260
if err != nil {
286261
log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_APPROVING_REVIEWS, protection.Repository.Name, protection.Pattern, d.Id())
@@ -292,10 +267,7 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{}
292267
log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_STATUS_CHECKS, protection.Repository.Name, protection.Pattern, d.Id())
293268
}
294269

295-
restrictsPushes, err := setPushes(protection, d, meta)
296-
if err != nil {
297-
return err
298-
}
270+
restrictsPushes := setPushes(protection)
299271
err = d.Set(PROTECTION_RESTRICTS_PUSHES, restrictsPushes)
300272
if err != nil {
301273
log.Printf("[DEBUG] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_RESTRICTS_PUSHES, protection.Repository.Name, protection.Pattern, d.Id())
@@ -316,27 +288,6 @@ func resourceGithubBranchProtectionUpdate(d *schema.ResourceData, meta interface
316288
if err != nil {
317289
return err
318290
}
319-
320-
var reviewIds, pushIds, bypassIds []string
321-
reviewIds, err = getActorIds(data.ReviewDismissalActorIDs, meta)
322-
if err != nil {
323-
return err
324-
}
325-
326-
pushIds, err = getActorIds(data.PushActorIDs, meta)
327-
if err != nil {
328-
return err
329-
}
330-
331-
bypassIds, err = getActorIds(data.BypassPullRequestActorIDs, meta)
332-
if err != nil {
333-
return err
334-
}
335-
336-
data.PushActorIDs = pushIds
337-
data.ReviewDismissalActorIDs = reviewIds
338-
data.BypassPullRequestActorIDs = bypassIds
339-
340291
input := githubv4.UpdateBranchProtectionRuleInput{
341292
BranchProtectionRuleID: d.Id(),
342293
AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)),

github/resource_github_branch_protection_test.go

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -380,60 +380,6 @@ func TestAccGithubBranchProtection(t *testing.T) {
380380

381381
})
382382

383-
t.Run("configures branch push restrictions with username", func(t *testing.T) {
384-
385-
user := fmt.Sprintf("/%s", testOwnerFunc())
386-
config := fmt.Sprintf(`
387-
resource "github_repository" "test" {
388-
name = "tf-acc-test-%s"
389-
auto_init = true
390-
}
391-
392-
resource "github_branch_protection" "test" {
393-
394-
repository_id = github_repository.test.name
395-
pattern = "main"
396-
397-
push_restrictions = [
398-
"%s",
399-
]
400-
401-
}
402-
`, randomID, user)
403-
404-
check := resource.ComposeAggregateTestCheckFunc(
405-
resource.TestCheckResourceAttr(
406-
"github_branch_protection.test", "push_restrictions.#", "1",
407-
),
408-
)
409-
410-
testCase := func(t *testing.T, mode string) {
411-
resource.Test(t, resource.TestCase{
412-
PreCheck: func() { skipUnlessMode(t, mode) },
413-
Providers: testAccProviders,
414-
Steps: []resource.TestStep{
415-
{
416-
Config: config,
417-
Check: check,
418-
},
419-
},
420-
})
421-
}
422-
423-
t.Run("with an anonymous account", func(t *testing.T) {
424-
t.Skip("anonymous account not supported for this operation")
425-
})
426-
427-
t.Run("with an individual account", func(t *testing.T) {
428-
t.Skip("individual account not supported for this operation")
429-
})
430-
431-
t.Run("with an organization account", func(t *testing.T) {
432-
testCase(t, organization)
433-
})
434-
435-
})
436-
437383
t.Run("configures force pushes and deletions", func(t *testing.T) {
438384

439385
config := fmt.Sprintf(`

github/resource_github_repository_environment.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,9 @@ func resourceGithubRepositoryEnvironmentRead(d *schema.ResourceData, meta interf
134134
for _, r := range pr.Reviewers {
135135
switch *r.Type {
136136
case "Team":
137-
if r.Reviewer.(*github.Team).ID != nil {
138-
teams = append(teams, *r.Reviewer.(*github.Team).ID)
139-
}
137+
teams = append(teams, *r.Reviewer.(*github.Team).ID)
140138
case "User":
141-
if r.Reviewer.(*github.User).ID != nil {
142-
users = append(users, *r.Reviewer.(*github.User).ID)
143-
}
139+
users = append(users, *r.Reviewer.(*github.User).ID)
144140
}
145141
}
146142
d.Set("reviewers", []interface{}{

0 commit comments

Comments
 (0)