Skip to content

Commit 1b8d6fb

Browse files
authored
feat!: Add repository query option to ListCustomPropertyValues (#3598)
BREAKING CHANGE: `ListCustomPropertyValues` now takes `ListCustomPropertyValuesOptions` instead of `ListOptions`.
1 parent ad671c4 commit 1b8d6fb

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

github/orgs_properties.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ type CustomPropertyValue struct {
4848
Value any `json:"value"`
4949
}
5050

51+
// ListCustomPropertyValuesOptions specifies the optional parameters to the
52+
// OrganizationsService.ListCustomPropertyValues method.
53+
type ListCustomPropertyValuesOptions struct {
54+
RepositoryQuery string `url:"repository_query,omitempty"`
55+
ListOptions
56+
}
57+
5158
// UnmarshalJSON implements the json.Unmarshaler interface.
5259
// This helps us handle the fact that Value can be either a string, []string, or nil.
5360
func (cpv *CustomPropertyValue) UnmarshalJSON(data []byte) error {
@@ -197,7 +204,7 @@ func (s *OrganizationsService) RemoveCustomProperty(ctx context.Context, org, cu
197204
// GitHub API docs: https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories
198205
//
199206
//meta:operation GET /orgs/{org}/properties/values
200-
func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *ListOptions) ([]*RepoCustomPropertyValue, *Response, error) {
207+
func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *ListCustomPropertyValuesOptions) ([]*RepoCustomPropertyValue, *Response, error) {
201208
u := fmt.Sprintf("orgs/%v/properties/values", org)
202209
u, err := addOptions(u, opts)
203210
if err != nil {

github/orgs_properties_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {
283283

284284
mux.HandleFunc("/orgs/o/properties/values", func(w http.ResponseWriter, r *http.Request) {
285285
testMethod(t, r, "GET")
286-
testFormValues(t, r, values{"page": "1", "per_page": "100"})
286+
testFormValues(t, r, values{
287+
"page": "1",
288+
"per_page": "100",
289+
"repository_query": "repo:octocat/Hello-World",
290+
})
287291
fmt.Fprint(w, `[{
288292
"repository_id": 1296269,
289293
"repository_name": "Hello-World",
@@ -310,9 +314,12 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {
310314
})
311315

312316
ctx := context.Background()
313-
repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &ListOptions{
314-
Page: 1,
315-
PerPage: 100,
317+
repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &ListCustomPropertyValuesOptions{
318+
ListOptions: ListOptions{
319+
Page: 1,
320+
PerPage: 100,
321+
},
322+
RepositoryQuery: "repo:octocat/Hello-World",
316323
})
317324
if err != nil {
318325
t.Errorf("Organizations.ListCustomPropertyValues returned error: %v", err)
@@ -351,7 +358,7 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {
351358
const methodName = "ListCustomPropertyValues"
352359

353360
testBadOptions(t, methodName, func() (err error) {
354-
_, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &ListOptions{})
361+
_, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &ListCustomPropertyValuesOptions{})
355362
return err
356363
})
357364

0 commit comments

Comments
 (0)