From ece4206ccae442c61a7fa9045ba871059f106297 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Thu, 24 Jul 2025 23:57:48 +0200 Subject: [PATCH] Add `FieldValue` field to `ProjectV2ItemChange` event. --- github/event_types.go | 11 +++++++ github/github-accessors.go | 40 +++++++++++++++++++++++++ github/github-accessors_test.go | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/github/event_types.go b/github/event_types.go index 3aa151e5ca7..6e285937fa0 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -1146,6 +1146,7 @@ type ProjectV2ItemEvent struct { // ProjectV2ItemChange represents a project v2 item change. type ProjectV2ItemChange struct { ArchivedAt *ArchivedAt `json:"archived_at,omitempty"` + FieldValue *FieldValue `json:"field_value,omitempty"` } // ArchivedAt represents an archiving date change. @@ -1154,6 +1155,16 @@ type ArchivedAt struct { To *Timestamp `json:"to,omitempty"` } +// FieldValue represents an editing field value change. +type FieldValue struct { + FieldNodeID *string `json:"field_node_id,omitempty"` + FieldType *string `json:"field_type,omitempty"` + FieldName *string `json:"field_name,omitempty"` + ProjectNumber *int64 `json:"project_number,omitempty"` + From json.RawMessage `json:"from,omitempty"` + To json.RawMessage `json:"to,omitempty"` +} + // ProjectV2Item represents an item belonging to a project. type ProjectV2Item struct { ID *int64 `json:"id,omitempty"` diff --git a/github/github-accessors.go b/github/github-accessors.go index b9d8bcf7e65..7edf3a4cdf0 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9190,6 +9190,38 @@ func (f *Feeds) GetUserURL() string { return *f.UserURL } +// GetFieldName returns the FieldName field if it's non-nil, zero value otherwise. +func (f *FieldValue) GetFieldName() string { + if f == nil || f.FieldName == nil { + return "" + } + return *f.FieldName +} + +// GetFieldNodeID returns the FieldNodeID field if it's non-nil, zero value otherwise. +func (f *FieldValue) GetFieldNodeID() string { + if f == nil || f.FieldNodeID == nil { + return "" + } + return *f.FieldNodeID +} + +// GetFieldType returns the FieldType field if it's non-nil, zero value otherwise. +func (f *FieldValue) GetFieldType() string { + if f == nil || f.FieldType == nil { + return "" + } + return *f.FieldType +} + +// GetProjectNumber returns the ProjectNumber field if it's non-nil, zero value otherwise. +func (f *FieldValue) GetProjectNumber() int64 { + if f == nil || f.ProjectNumber == nil { + return 0 + } + return *f.ProjectNumber +} + // GetIdentifier returns the Identifier field if it's non-nil, zero value otherwise. func (f *FirstPatchedVersion) GetIdentifier() string { if f == nil || f.Identifier == nil { @@ -18438,6 +18470,14 @@ func (p *ProjectV2ItemChange) GetArchivedAt() *ArchivedAt { return p.ArchivedAt } +// GetFieldValue returns the FieldValue field. +func (p *ProjectV2ItemChange) GetFieldValue() *FieldValue { + if p == nil { + return nil + } + return p.FieldValue +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (p *ProjectV2ItemEvent) GetAction() string { if p == nil || p.Action == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index f6a191ee0f8..38a1fda432e 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -11885,6 +11885,50 @@ func TestFeeds_GetUserURL(tt *testing.T) { f.GetUserURL() } +func TestFieldValue_GetFieldName(tt *testing.T) { + tt.Parallel() + var zeroValue string + f := &FieldValue{FieldName: &zeroValue} + f.GetFieldName() + f = &FieldValue{} + f.GetFieldName() + f = nil + f.GetFieldName() +} + +func TestFieldValue_GetFieldNodeID(tt *testing.T) { + tt.Parallel() + var zeroValue string + f := &FieldValue{FieldNodeID: &zeroValue} + f.GetFieldNodeID() + f = &FieldValue{} + f.GetFieldNodeID() + f = nil + f.GetFieldNodeID() +} + +func TestFieldValue_GetFieldType(tt *testing.T) { + tt.Parallel() + var zeroValue string + f := &FieldValue{FieldType: &zeroValue} + f.GetFieldType() + f = &FieldValue{} + f.GetFieldType() + f = nil + f.GetFieldType() +} + +func TestFieldValue_GetProjectNumber(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + f := &FieldValue{ProjectNumber: &zeroValue} + f.GetProjectNumber() + f = &FieldValue{} + f.GetProjectNumber() + f = nil + f.GetProjectNumber() +} + func TestFirstPatchedVersion_GetIdentifier(tt *testing.T) { tt.Parallel() var zeroValue string @@ -23911,6 +23955,14 @@ func TestProjectV2ItemChange_GetArchivedAt(tt *testing.T) { p.GetArchivedAt() } +func TestProjectV2ItemChange_GetFieldValue(tt *testing.T) { + tt.Parallel() + p := &ProjectV2ItemChange{} + p.GetFieldValue() + p = nil + p.GetFieldValue() +} + func TestProjectV2ItemEvent_GetAction(tt *testing.T) { tt.Parallel() var zeroValue string