From 70d1becaf2e968f9b2b9773f461143a098ff9e87 Mon Sep 17 00:00:00 2001 From: Christopher Trom Date: Fri, 7 Sep 2018 14:28:48 -0500 Subject: [PATCH 1/2] resource/github_repository: Allow setting default branch to master for new repo --- github/resource_github_repository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index 3b07d8ffba..f65177152a 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -157,8 +157,8 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository { func resourceGithubRepositoryCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*Organization).client - if _, ok := d.GetOk("default_branch"); ok { - return fmt.Errorf("Cannot set the default branch on a new repository.") + if branchName, hasDefaultBranch := d.GetOk("default_branch"); hasDefaultBranch && (branchName != "master") { + return fmt.Errorf("Cannot set the default branch on a new repository to something other than 'master'.") } orgName := meta.(*Organization).name From 12610f6c3577d28063979bb82302c4cedf5a130a Mon Sep 17 00:00:00 2001 From: Tracy Holmes Date: Thu, 18 Jul 2019 17:32:39 -0500 Subject: [PATCH 2/2] Adds test to validate repository can be set to master as default upon creation --- github/resource_github_repository_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index 9b3682c152..fcd9ce7141 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -739,6 +739,7 @@ resource "github_repository" "foo" { allow_rebase_merge = false has_downloads = true auto_init = true + default_branch = "master" } `, randString, randString) }