Skip to content

Commit

Permalink
Add allow_auto_merge option for repositories (integrations#923)
Browse files Browse the repository at this point in the history
Support enabling auto-merge on a repository as per integrations#649
  • Loading branch information
lauraseidler authored Oct 17, 2021
1 parent a083e5f commit 36e16ce
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func dataSourceGithubRepository() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"allow_auto_merge": {
Type: schema.TypeBool,
Computed: true,
},
"default_branch": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -216,6 +220,7 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
d.Set("allow_merge_commit", repo.GetAllowMergeCommit())
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
d.Set("has_downloads", repo.GetHasDownloads())
d.Set("full_name", repo.GetFullName())
d.Set("default_branch", repo.GetDefaultBranch())
Expand Down
7 changes: 7 additions & 0 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func resourceGithubRepository() *schema.Resource {
Optional: true,
Default: true,
},
"allow_auto_merge": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"delete_branch_on_merge": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -268,6 +273,7 @@ func resourceGithubRepositoryObject(d *schema.ResourceData) *github.Repository {
AllowMergeCommit: github.Bool(d.Get("allow_merge_commit").(bool)),
AllowSquashMerge: github.Bool(d.Get("allow_squash_merge").(bool)),
AllowRebaseMerge: github.Bool(d.Get("allow_rebase_merge").(bool)),
AllowAutoMerge: github.Bool(d.Get("allow_auto_merge").(bool)),
DeleteBranchOnMerge: github.Bool(d.Get("delete_branch_on_merge").(bool)),
AutoInit: github.Bool(d.Get("auto_init").(bool)),
LicenseTemplate: github.String(d.Get("license_template").(string)),
Expand Down Expand Up @@ -416,6 +422,7 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("allow_merge_commit", repo.GetAllowMergeCommit())
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
d.Set("delete_branch_on_merge", repo.GetDeleteBranchOnMerge())
d.Set("has_downloads", repo.GetHasDownloads())
d.Set("full_name", repo.GetFullName())
Expand Down
5 changes: 5 additions & 0 deletions github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccGithubRepositories(t *testing.T) {
allow_merge_commit = true
allow_squash_merge = false
allow_rebase_merge = false
allow_auto_merge = true
auto_init = false
}
Expand All @@ -40,6 +41,10 @@ func TestAccGithubRepositories(t *testing.T) {
"github_repository.test", "has_issues",
"true",
),
resource.TestCheckResourceAttr(
"github_repository.test", "allow_auto_merge",
"true",
),
)

testCase := func(t *testing.T, mode string) {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ The following arguments are supported:

* `allow_rebase_merge` - Whether the repository allows rebase merges.

* `allow_auto_merge` - Whether the repository allows auto-merging pull requests.

* `has_downloads` - Whether the repository has Downloads feature enabled.

* `default_branch` - The name of the default branch of the repository.
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 @@ -75,6 +75,8 @@ The following arguments are supported:

* `allow_rebase_merge` - (Optional) Set to `false` to disable rebase merges on the repository.

* `allow_auto_merge` - (Optional) Set to `true` to allow auto-merging pull requests on the repository.

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

* `has_downloads` - (Optional) Set to `true` to enable the (deprecated) downloads features on the repository.
Expand Down

0 comments on commit 36e16ce

Please sign in to comment.