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

feat: allow_update_branch argument #1143

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ func resourceGithubRepository() *schema.Resource {
Type: schema.TypeInt,
Computed: true,
},
"allow_update_branch": {
Type: schema.TypeBool,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -309,14 +313,15 @@ 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()),
AllowUpdateBranch: github.Bool(d.Get("allow_update_branch").(bool)),
}
}

func resourceGithubRepositoryCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Owner).v3client

if branchName, hasDefaultBranch := d.GetOk("default_branch"); hasDefaultBranch && (branchName != "main") {
return fmt.Errorf("cannot set the default branch on a new repository to something other than 'main'.")
return fmt.Errorf("cannot set the default branch on a new repository to something other than 'main'")
}

repoReq := resourceGithubRepositoryObject(d)
Expand Down Expand Up @@ -456,6 +461,8 @@ func resourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) erro
d.Set("topics", flattenStringList(repo.Topics))
d.Set("node_id", repo.GetNodeID())
d.Set("repo_id", repo.GetID())
d.Set("allow_update_branch", repo.GetAllowUpdateBranch())

// GitHub API doesn't respond following parameters when repository is archived
if !d.Get("archived").(bool) {
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
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 @@ -113,6 +113,8 @@ initial repository creation and create the target branch inside of the repositor

* `ignore_vulnerability_alerts_during_read` (Optional) - Set to `true` to not call the vulnerability alerts endpoint so the resource can also be used without admin permissions during read.

* `allow_update_branch` (Optional) - Set to `true` to always suggest updating pull request branches.

### GitHub Pages Configuration

The `pages` block supports the following:
Expand Down