From ca360914beb3c5f6adb658f8e5c7f081ec97cfcb Mon Sep 17 00:00:00 2001 From: hnkz Date: Tue, 24 Jun 2025 19:14:58 +0900 Subject: [PATCH 1/3] Add repository query option to ListCustomPropertyValues --- github/orgs_properties.go | 9 ++++++++- github/orgs_properties_test.go | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/github/orgs_properties.go b/github/orgs_properties.go index 09abdffbfcb..f46d3718d9f 100644 --- a/github/orgs_properties.go +++ b/github/orgs_properties.go @@ -48,6 +48,13 @@ type CustomPropertyValue struct { Value any `json:"value"` } +// CustomPropertyValuesListOptions specifies the optional parameters to the +// OrganizationsService.ListCustomPropertyValues method. +type CustomPropertyValuesListOptions struct { + RepositoryQuery string `url:"repository_query,omitempty"` + ListOptions +} + // UnmarshalJSON implements the json.Unmarshaler interface. // This helps us handle the fact that Value can be either a string, []string, or nil. func (cpv *CustomPropertyValue) UnmarshalJSON(data []byte) error { @@ -197,7 +204,7 @@ func (s *OrganizationsService) RemoveCustomProperty(ctx context.Context, org, cu // GitHub API docs: https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories // //meta:operation GET /orgs/{org}/properties/values -func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *ListOptions) ([]*RepoCustomPropertyValue, *Response, error) { +func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *CustomPropertyValuesListOptions) ([]*RepoCustomPropertyValue, *Response, error) { u := fmt.Sprintf("orgs/%v/properties/values", org) u, err := addOptions(u, opts) if err != nil { diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index 96b90fb7c2d..095be84e390 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -283,7 +283,11 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) { mux.HandleFunc("/orgs/o/properties/values", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testFormValues(t, r, values{"page": "1", "per_page": "100"}) + testFormValues(t, r, values{ + "page": "1", + "per_page": "100", + "repository_query": "repo:octocat/Hello-World", + }) fmt.Fprint(w, `[{ "repository_id": 1296269, "repository_name": "Hello-World", @@ -310,9 +314,12 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) { }) ctx := context.Background() - repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &ListOptions{ - Page: 1, - PerPage: 100, + repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &CustomPropertyValuesListOptions{ + ListOptions: ListOptions{ + Page: 1, + PerPage: 100, + }, + RepositoryQuery: "repo:octocat/Hello-World", }) if err != nil { t.Errorf("Organizations.ListCustomPropertyValues returned error: %v", err) @@ -351,7 +358,7 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) { const methodName = "ListCustomPropertyValues" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &ListOptions{}) + _, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &CustomPropertyValuesListOptions{}) return err }) From 06ac6a53b168a42ceb39a851951c2b73127f4e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?hnk=C6=B6?= Date: Tue, 24 Jun 2025 21:29:09 +0900 Subject: [PATCH 2/3] Update github/orgs_properties.go Co-authored-by: Oleksandr Redko --- github/orgs_properties.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/orgs_properties.go b/github/orgs_properties.go index f46d3718d9f..cd8a937c1e5 100644 --- a/github/orgs_properties.go +++ b/github/orgs_properties.go @@ -50,7 +50,7 @@ type CustomPropertyValue struct { // CustomPropertyValuesListOptions specifies the optional parameters to the // OrganizationsService.ListCustomPropertyValues method. -type CustomPropertyValuesListOptions struct { +type ListCustomPropertyValuesOptions struct { RepositoryQuery string `url:"repository_query,omitempty"` ListOptions } From d3d65e676b2eebf1a7856600c04462dcbaeeeda5 Mon Sep 17 00:00:00 2001 From: hnkz Date: Tue, 24 Jun 2025 21:39:17 +0900 Subject: [PATCH 3/3] Rename CustomPropertyValuesListOptions to ListCustomPropertyValuesOptions for consistent naming --- github/orgs_properties.go | 4 ++-- github/orgs_properties_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/github/orgs_properties.go b/github/orgs_properties.go index cd8a937c1e5..257e765993b 100644 --- a/github/orgs_properties.go +++ b/github/orgs_properties.go @@ -48,7 +48,7 @@ type CustomPropertyValue struct { Value any `json:"value"` } -// CustomPropertyValuesListOptions specifies the optional parameters to the +// ListCustomPropertyValuesOptions specifies the optional parameters to the // OrganizationsService.ListCustomPropertyValues method. type ListCustomPropertyValuesOptions struct { RepositoryQuery string `url:"repository_query,omitempty"` @@ -204,7 +204,7 @@ func (s *OrganizationsService) RemoveCustomProperty(ctx context.Context, org, cu // GitHub API docs: https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories // //meta:operation GET /orgs/{org}/properties/values -func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *CustomPropertyValuesListOptions) ([]*RepoCustomPropertyValue, *Response, error) { +func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *ListCustomPropertyValuesOptions) ([]*RepoCustomPropertyValue, *Response, error) { u := fmt.Sprintf("orgs/%v/properties/values", org) u, err := addOptions(u, opts) if err != nil { diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index 095be84e390..ceab4525171 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -314,7 +314,7 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) { }) ctx := context.Background() - repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &CustomPropertyValuesListOptions{ + repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &ListCustomPropertyValuesOptions{ ListOptions: ListOptions{ Page: 1, PerPage: 100, @@ -358,7 +358,7 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) { const methodName = "ListCustomPropertyValues" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &CustomPropertyValuesListOptions{}) + _, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &ListCustomPropertyValuesOptions{}) return err })