Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for auto_delete_head_branch #265

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ func resourceGithubRepository() *schema.Resource {
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`), "must include only lowercase alphanumeric characters or hyphens and cannot start with a hyphen"),
},
},

"auto_delete_head_branch": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"full_name": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -178,6 +182,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
GitignoreTemplate: github.String(d.Get("gitignore_template").(string)),
Archived: github.Bool(d.Get("archived").(bool)),
Topics: expandStringList(d.Get("topics").(*schema.Set).List()),
DeleteBranchOnMerge: github.Bool(d.Get("auto_delete_head_branch").(bool)),
}
}

Expand Down Expand Up @@ -304,6 +309,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("http_clone_url", repo.CloneURL)
d.Set("archived", repo.Archived)
d.Set("topics", flattenStringList(repo.Topics))
d.Set("auto_delete_head_branch", repo.DeleteBranchOnMerge)

if repo.TemplateRepository != nil {
d.Set("template", []interface{}{
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ initial repository creation and create the target branch inside of the repositor

* `topics` - (Optional) The list of topics of the repository.

* `auto_delete_head_branch` - (Optional) Automatically delete head branch after a pull request is merged. Defaults to `false`.

* `template` - (Optional) Use a template repository to create this resource. See [Template Repositories](#template-repositories) below for details.

### Template Repositories
Expand Down