Skip to content

Commit

Permalink
resource/github_repository: Allow setting default_branch to `m… (#150)
Browse files Browse the repository at this point in the history
* resource/github_repository: Allow setting default branch to master for new repo

* Adds test to validate repository can be set to master as default upon creation
  • Loading branch information
ctrom authored and tracypholmes committed Jul 18, 2019
1 parent 400cb4d commit 45fb8bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func resourceGithubRepositoryCreate(d *schema.ResourceData, meta interface{}) er

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
Expand Down
1 change: 1 addition & 0 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ resource "github_repository" "foo" {
allow_rebase_merge = false
has_downloads = true
auto_init = true
default_branch = "master"
}
`, randString, randString)
}
Expand Down

0 comments on commit 45fb8bf

Please sign in to comment.