Skip to content

Commit

Permalink
Bugfix: fix github_branch_protection required_status_checks not remov…
Browse files Browse the repository at this point in the history
…ing contexts (#1492)

* fix github_branch_protection removing required_status_check contexts

Now when github_branch_protection.required_status_checks.contexts is changed from a non-empty list to an empty list, all status checks are removed from the branch protection.

* remove now unused githubV4STringSlice function

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
  • Loading branch information
jtgrohn and kfcampbell authored Jan 17, 2023
1 parent f81d021 commit d27da35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions github/resource_github_branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func resourceGithubBranchProtectionCreate(d *schema.ResourceData, meta interface
PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)),
RepositoryID: githubv4.NewID(githubv4.ID(data.RepositoryID)),
RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)),
RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSlice(data.RequiredStatusCheckContexts)),
RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSliceEmpty(data.RequiredStatusCheckContexts)),
RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)),
RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)),
RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)),
Expand Down Expand Up @@ -368,7 +368,7 @@ func resourceGithubBranchProtectionUpdate(d *schema.ResourceData, meta interface
Pattern: githubv4.NewString(githubv4.String(data.Pattern)),
PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)),
RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)),
RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSlice(data.RequiredStatusCheckContexts)),
RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSliceEmpty(data.RequiredStatusCheckContexts)),
RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)),
RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)),
RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)),
Expand Down
4 changes: 2 additions & 2 deletions github/util_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func expandNestedSet(m map[string]interface{}, target string) []string {
return res
}

func githubv4StringSlice(ss []string) []githubv4.String {
var vGh4 []githubv4.String
func githubv4StringSliceEmpty(ss []string) []githubv4.String {
vGh4 := make([]githubv4.String, 0)
for _, s := range ss {
vGh4 = append(vGh4, githubv4.String(s))
}
Expand Down

0 comments on commit d27da35

Please sign in to comment.