From e19940baf21f6f12fee1ba68e428bd8ecf11794a Mon Sep 17 00:00:00 2001 From: IrvingMg Date: Sat, 13 Dec 2025 13:33:57 +0100 Subject: [PATCH 1/2] Add support for URL custom property value type --- github/orgs_properties.go | 2 +- github/orgs_properties_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/github/orgs_properties.go b/github/orgs_properties.go index 0c23c91b227..17871588a04 100644 --- a/github/orgs_properties.go +++ b/github/orgs_properties.go @@ -21,7 +21,7 @@ type CustomProperty struct { URL *string `json:"url,omitempty"` // SourceType is the source type of the property where it has been created. Can be one of: organization, enterprise. SourceType *string `json:"source_type,omitempty"` - // The type of the value for the property. Can be one of: string, single_select, multi_select, true_false. + // The type of the value for the property. Can be one of: string, single_select, multi_select, true_false, url. ValueType string `json:"value_type"` // Whether the property is required. Required *bool `json:"required,omitempty"` diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index 7ff20fd34c7..e8db5c003d8 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -40,6 +40,13 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { "property_name": "team", "value_type": "string", "description": "Team owning the repository" + }, + { + "property_name": "documentation", + "value_type": "url", + "required": true, + "description": "Link to the documentation", + "default_value": "https://example.com/docs" } ]`) }) @@ -69,6 +76,13 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { ValueType: "string", Description: Ptr("Team owning the repository"), }, + { + PropertyName: Ptr("documentation"), + ValueType: "url", + Required: Ptr(true), + Description: Ptr("Link to the documentation"), + DefaultValue: Ptr("https://example.com/docs"), + }, } if !cmp.Equal(properties, want) { t.Errorf("Organizations.GetAllCustomProperties returned %+v, want %+v", properties, want) From 1356164a2091211d48aaecc94cd43945df64d129 Mon Sep 17 00:00:00 2001 From: IrvingMg Date: Sun, 14 Dec 2025 15:45:10 +0100 Subject: [PATCH 2/2] Add constants for CustomProperty.ValueType --- ...enterprise_organization_properties_test.go | 4 ++-- github/enterprise_properties_test.go | 20 ++++++++--------- github/event_types_test.go | 2 +- github/orgs_properties.go | 9 ++++++++ github/orgs_properties_test.go | 22 +++++++++---------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/github/enterprise_organization_properties_test.go b/github/enterprise_organization_properties_test.go index 2248285bd3f..567676eafb3 100644 --- a/github/enterprise_organization_properties_test.go +++ b/github/enterprise_organization_properties_test.go @@ -38,7 +38,7 @@ func TestEnterpriseService_GetOrganizationCustomPropertySchema(t *testing.T) { Properties: []*CustomProperty{ { PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team name"), }, }, @@ -111,7 +111,7 @@ func TestEnterpriseService_GetOrganizationCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team name"), } diff --git a/github/enterprise_properties_test.go b/github/enterprise_properties_test.go index 5aa524f4ed2..94bf1db966c 100644 --- a/github/enterprise_properties_test.go +++ b/github/enterprise_properties_test.go @@ -53,7 +53,7 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -62,11 +62,11 @@ func TestEnterpriseService_GetAllCustomProperties(t *testing.T) { }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, { PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team owning the repository"), }, } @@ -109,12 +109,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) { properties, _, err := client.Enterprise.CreateOrUpdateCustomProperties(ctx, "e", []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, }) if err != nil { @@ -124,12 +124,12 @@ func TestEnterpriseService_CreateOrUpdateCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, } @@ -176,7 +176,7 @@ func TestEnterpriseService_GetCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -220,7 +220,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) { ctx := t.Context() property, _, err := client.Enterprise.CreateOrUpdateCustomProperty(ctx, "e", "name", &CustomProperty{ - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -233,7 +233,7 @@ func TestEnterpriseService_CreateOrUpdateCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), diff --git a/github/event_types_test.go b/github/event_types_test.go index 15881ab6cec..ec0aa1c0ba3 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -13729,7 +13729,7 @@ func TestCustomPropertyEvent_Marshal(t *testing.T) { Action: Ptr("created"), Definition: &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, SourceType: Ptr("enterprise"), Required: Ptr(true), DefaultValue: Ptr("production"), diff --git a/github/orgs_properties.go b/github/orgs_properties.go index 17871588a04..502713b8bac 100644 --- a/github/orgs_properties.go +++ b/github/orgs_properties.go @@ -12,6 +12,15 @@ import ( "fmt" ) +// Valid values for CustomProperty.ValueType. +const ( + PropertyValueTypeString = "string" + PropertyValueTypeSingleSelect = "single_select" + PropertyValueTypeMultiSelect = "multi_select" + PropertyValueTypeTrueFalse = "true_false" + PropertyValueTypeURL = "url" +) + // CustomProperty represents an organization custom property object. type CustomProperty struct { // PropertyName is required for most endpoints except when calling CreateOrUpdateCustomProperty; diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index e8db5c003d8..bac673d3eed 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -60,7 +60,7 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -69,16 +69,16 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) { }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, { PropertyName: Ptr("team"), - ValueType: "string", + ValueType: PropertyValueTypeString, Description: Ptr("Team owning the repository"), }, { PropertyName: Ptr("documentation"), - ValueType: "url", + ValueType: PropertyValueTypeURL, Required: Ptr(true), Description: Ptr("Link to the documentation"), DefaultValue: Ptr("https://example.com/docs"), @@ -123,12 +123,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) { properties, _, err := client.Organizations.CreateOrUpdateCustomProperties(ctx, "o", []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, }) if err != nil { @@ -138,12 +138,12 @@ func TestOrganizationsService_CreateOrUpdateCustomProperties(t *testing.T) { want := []*CustomProperty{ { PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), }, { PropertyName: Ptr("service"), - ValueType: "string", + ValueType: PropertyValueTypeString, }, } @@ -190,7 +190,7 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -234,7 +234,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) { ctx := t.Context() property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{ - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"), @@ -247,7 +247,7 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) { want := &CustomProperty{ PropertyName: Ptr("name"), - ValueType: "single_select", + ValueType: PropertyValueTypeSingleSelect, Required: Ptr(true), DefaultValue: Ptr("production"), Description: Ptr("Prod or dev environment"),