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

Replaying the changes in #1162 without the binary #1234

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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