Skip to content

Commit 7f07245

Browse files
committed
fix: Correct private forking implementation
Signed-off-by: Steve Hipwell <[email protected]>
1 parent d5f775e commit 7f07245

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

github/resource_github_repository.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func resourceGithubRepository() *schema.Resource {
249249
"allow_forking": {
250250
Type: schema.TypeBool,
251251
Optional: true,
252-
Default: false,
252+
Computed: true,
253253
Description: "Set to 'true' to allow private forking on the repository; this is only relevant if the repository is owned by an organization and is private or internal.",
254254
},
255255
"squash_merge_commit_title": {
@@ -580,11 +580,13 @@ func calculateSecurityAndAnalysis(d *schema.ResourceData) *github.SecurityAndAna
580580
}
581581

582582
func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
583+
visibility := calculateVisibility(d)
584+
583585
repository := &github.Repository{
584586
Name: github.Ptr(d.Get("name").(string)),
585587
Description: github.Ptr(d.Get("description").(string)),
586588
Homepage: github.Ptr(d.Get("homepage_url").(string)),
587-
Visibility: github.Ptr(calculateVisibility(d)),
589+
Visibility: github.Ptr(visibility),
588590
HasDownloads: github.Ptr(d.Get("has_downloads").(bool)),
589591
HasIssues: github.Ptr(d.Get("has_issues").(bool)),
590592
HasDiscussions: github.Ptr(d.Get("has_discussions").(bool)),
@@ -595,7 +597,6 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
595597
AllowSquashMerge: github.Ptr(d.Get("allow_squash_merge").(bool)),
596598
AllowRebaseMerge: github.Ptr(d.Get("allow_rebase_merge").(bool)),
597599
AllowAutoMerge: github.Ptr(d.Get("allow_auto_merge").(bool)),
598-
AllowForking: github.Ptr(d.Get("allow_forking").(bool)),
599600
DeleteBranchOnMerge: github.Ptr(d.Get("delete_branch_on_merge").(bool)),
600601
WebCommitSignoffRequired: github.Ptr(d.Get("web_commit_signoff_required").(bool)),
601602
AutoInit: github.Ptr(d.Get("auto_init").(bool)),
@@ -625,6 +626,12 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
625626
}
626627
}
627628

629+
// only configure allow forking if repository is not public
630+
allowForking, ok := d.Get("allow_forking").(bool)
631+
if ok && visibility != "public" {
632+
repository.AllowForking = github.Ptr(allowForking)
633+
}
634+
628635
return repository
629636
}
630637

0 commit comments

Comments
 (0)