From d4b2f5b4609971b8636234b955517ed95e305496 Mon Sep 17 00:00:00 2001 From: Tom Withers Date: Tue, 6 Aug 2019 08:30:20 +0100 Subject: [PATCH 1/3] Add support for auto_delete_head_branch --- github/resource_github_repository.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index 5e4d9948e5..ffda670644 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -108,7 +108,6 @@ 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"), }, }, - "full_name": { Type: schema.TypeString, Computed: true, @@ -137,6 +136,10 @@ func resourceGithubRepository() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "auto_delete_head_branch": { + Type: schema.TypeBool, + Computed: true, + }, }, } } @@ -159,6 +162,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()), + } } From 7887dcacddcfdca0386093466fe9c9e22f5f92b0 Mon Sep 17 00:00:00 2001 From: Tom Withers Date: Mon, 17 Feb 2020 15:17:58 +0000 Subject: [PATCH 2/3] Make auto_delete_head_branch an optional --- github/resource_github_repository.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index ffda670644..982c7bb579 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -108,6 +108,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, @@ -136,10 +141,6 @@ func resourceGithubRepository() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "auto_delete_head_branch": { - Type: schema.TypeBool, - Computed: true, - }, }, } } @@ -162,7 +163,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)), } } @@ -254,6 +255,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) return nil } From b59bfd7327978c23fcedc20041127697eee97320 Mon Sep 17 00:00:00 2001 From: Tom Withers Date: Tue, 18 Feb 2020 06:45:21 +0000 Subject: [PATCH 3/3] Add auto_delete_head_branch to docs --- website/docs/r/repository.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/repository.html.markdown b/website/docs/r/repository.html.markdown index ede05a4232..6fd30ef3db 100644 --- a/website/docs/r/repository.html.markdown +++ b/website/docs/r/repository.html.markdown @@ -65,11 +65,11 @@ The following arguments are supported: and after a correct reference has been created for the target branch inside the repository. This means a user will have to omit this parameter from the initial repository creation and create the target branch inside of the repository prior to setting this attribute. -* `archived` - (Optional) Specifies if the repository should be archived. Defaults to `false`. +* `archived` - (Optional) Specifies if the repository should be archived. Defaults to `false`. ~> **NOTE** Currently, the API does not support unarchiving. * `topics` - (Optional) The list of topics of the repository. -~> **NOTE** Currently, the API does not support unarchiving. +* `auto_delete_head_branch` - (Optional) Automatically delete head branch after a pull request is merged. Defaults to `false`. ## Attributes Reference