From bd4a180bd3fb95b08b93f74ba4b9e6e20d70b396 Mon Sep 17 00:00:00 2001 From: Ivan Martos Date: Tue, 8 Oct 2024 10:26:50 +0200 Subject: [PATCH 1/2] feat: export createdAt and updatedAt for ruleset --- github/repos_rules.go | 2 ++ github/repos_rules_test.go | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index d09bb71d103..ca9e9ea85bc 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -548,6 +548,8 @@ type Ruleset struct { Links *RulesetLinks `json:"_links,omitempty"` Conditions *RulesetConditions `json:"conditions,omitempty"` Rules []*RepositoryRule `json:"rules,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` } // rulesetNoOmitBypassActors represents a GitHub ruleset object. The struct does not omit bypassActors if the field is nil or an empty array is passed. diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index 809bd9a89a1..a34b84cd895 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -489,14 +489,18 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) { "name": "ruleset", "source_type": "Repository", "source": "o/repo", - "enforcement": "enabled" + "enforcement": "enabled", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }, { "id": 314, "name": "Another ruleset", "source_type": "Repository", "source": "o/repo", - "enforcement": "enabled" + "enforcement": "enabled", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` } ]`) }) @@ -514,6 +518,8 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) { SourceType: String("Repository"), Source: "o/repo", Enforcement: "enabled", + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, }, { ID: Int64(314), @@ -521,6 +527,8 @@ func TestRepositoriesService_GetAllRulesets(t *testing.T) { SourceType: String("Repository"), Source: "o/repo", Enforcement: "enabled", + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, }, } if !cmp.Equal(ruleSet, want) { @@ -683,7 +691,9 @@ func TestRepositoriesService_GetRuleset(t *testing.T) { "name": "ruleset", "source_type": "Organization", "source": "o", - "enforcement": "enabled" + "enforcement": "enabled", + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` }`) }) @@ -699,6 +709,8 @@ func TestRepositoriesService_GetRuleset(t *testing.T) { SourceType: String("Organization"), Source: "o", Enforcement: "enabled", + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, } if !cmp.Equal(ruleSet, want) { t.Errorf("Repositories.GetRuleset returned %+v, want %+v", ruleSet, want) From 8f11111b4a661a94a2b3f301dc3c73242374ab26 Mon Sep 17 00:00:00 2001 From: Ivan Martos Date: Tue, 8 Oct 2024 14:52:35 +0200 Subject: [PATCH 2/2] chore: add generated files --- github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index f8e303c4362..1c1f6c33e39 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -21150,6 +21150,14 @@ func (r *Ruleset) GetConditions() *RulesetConditions { return r.Conditions } +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (r *Ruleset) GetCreatedAt() Timestamp { + if r == nil || r.CreatedAt == nil { + return Timestamp{} + } + return *r.CreatedAt +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (r *Ruleset) GetID() int64 { if r == nil || r.ID == nil { @@ -21190,6 +21198,14 @@ func (r *Ruleset) GetTarget() string { return *r.Target } +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (r *Ruleset) GetUpdatedAt() Timestamp { + if r == nil || r.UpdatedAt == nil { + return Timestamp{} + } + return *r.UpdatedAt +} + // GetRefName returns the RefName field. func (r *RulesetConditions) GetRefName() *RulesetRefConditionParameters { if r == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index b9b4b08b256..4692094303f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -27208,6 +27208,17 @@ func TestRuleset_GetConditions(tt *testing.T) { r.GetConditions() } +func TestRuleset_GetCreatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + r := &Ruleset{CreatedAt: &zeroValue} + r.GetCreatedAt() + r = &Ruleset{} + r.GetCreatedAt() + r = nil + r.GetCreatedAt() +} + func TestRuleset_GetID(tt *testing.T) { tt.Parallel() var zeroValue int64 @@ -27260,6 +27271,17 @@ func TestRuleset_GetTarget(tt *testing.T) { r.GetTarget() } +func TestRuleset_GetUpdatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + r := &Ruleset{UpdatedAt: &zeroValue} + r.GetUpdatedAt() + r = &Ruleset{} + r.GetUpdatedAt() + r = nil + r.GetUpdatedAt() +} + func TestRulesetConditions_GetRefName(tt *testing.T) { tt.Parallel() r := &RulesetConditions{}