Skip to content

Commit

Permalink
Replaying the changes in integrations#1162 without the binary (integr…
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcampbell authored Jul 28, 2022
1 parent 24ad44b commit 45bb80f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func dataSourceGithubRepository() *schema.Resource {
Computed: true,
ConflictsWith: []string{"full_name"},
},
"only_protected_branches": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"description": {
Type: schema.TypeString,
Expand Down Expand Up @@ -242,7 +247,12 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
d.Set("repo_id", repo.GetID())
d.Set("has_projects", repo.GetHasProjects())

branches, _, err := client.Repositories.ListBranches(context.TODO(), owner, repoName, nil)
onlyProtectedBranches := d.Get("only_protected_branches").(bool)
listBranchOptions := &github.BranchListOptions{
Protected: &onlyProtectedBranches,
}

branches, _, err := client.Repositories.ListBranches(context.TODO(), owner, repoName, listBranchOptions)
if err != nil {
return err
}
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 @@ -25,6 +25,8 @@ The following arguments are supported:

* `full_name` - (Optional) Full name of the repository (in `org/name` format).

* `only_protected_branches` - (Optional). If true, the `branches` attributes will be populated only with protected branches. Default: `false`.

## Attributes Reference

* `node_id` - the Node ID of the repository.
Expand Down

0 comments on commit 45bb80f

Please sign in to comment.