Skip to content

Commit

Permalink
feat: allow_update_branch argument (integrations#1143)
Browse files Browse the repository at this point in the history
setting allows toggling "always suggest updating pull request branch"
repository setting

Signed-off-by: Sean Trantalis <strantalis@virtru.com>

Signed-off-by: Sean Trantalis <strantalis@virtru.com>
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
  • Loading branch information
2 people authored and kazaker committed Dec 28, 2022
1 parent ada1b6f commit c52f610
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit c52f610

Please sign in to comment.