Skip to content

Commit f85bfb8

Browse files
fixed repository environments so terraform will readd back in deployment branch protection if it is removed manually from GitHub (#1981)
Co-authored-by: Keegan Campbell <[email protected]>
1 parent 5aa1d77 commit f85bfb8

3 files changed

+4
-2
lines changed

github/resource_github_branch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func resourceGithubBranchImport(d *schema.ResourceData, meta interface{}) ([]*sc
191191

192192
// resourceGithubBranchRead calls d.SetId("") if the branch does not exist
193193
if d.Id() == "" {
194-
return nil, fmt.Errorf("repository %s does not have a branch named %s.", repoName, branchName)
194+
return nil, fmt.Errorf("repository %s does not have a branch named %s", repoName, branchName)
195195
}
196196

197197
return []*schema.ResourceData{d}, nil

github/resource_github_branch_protection_v3_utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func expandRequiredStatusChecks(d *schema.ResourceData) (*github.RequiredStatusC
283283
// If we have a valid app_id, include it in the RSC
284284
rscAppId, err := strconv.Atoi(cAppId)
285285
if err != nil {
286-
return nil, fmt.Errorf("Could not parse %v as valid app_id", cAppId)
286+
return nil, fmt.Errorf("could not parse %v as valid app_id", cAppId)
287287
}
288288
rscAppId64 := int64(rscAppId)
289289
rscCheck = &github.RequiredStatusCheck{Context: cContext, AppID: &rscAppId64}

github/resource_github_repository_environment.go

+2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ func resourceGithubRepositoryEnvironmentRead(d *schema.ResourceData, meta interf
172172
"custom_branch_policies": env.DeploymentBranchPolicy.CustomBranchPolicies,
173173
},
174174
})
175+
} else {
176+
d.Set("deployment_branch_policy", []interface{}{})
175177
}
176178

177179
return nil

0 commit comments

Comments
 (0)