From ac22060cd6d4f5e963d6bf64a6672fcb8e14194f Mon Sep 17 00:00:00 2001 From: Szymon Kodrebski Date: Tue, 20 Aug 2019 17:13:20 +0200 Subject: [PATCH 1/3] Add missing field in users_keys class --- github/users_keys.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/github/users_keys.go b/github/users_keys.go index ddc832a1ece..bb3d0402dfa 100644 --- a/github/users_keys.go +++ b/github/users_keys.go @@ -8,15 +8,17 @@ package github import ( "context" "fmt" + "time" ) // Key represents a public SSH key used to authenticate a user or deploy script. type Key struct { - ID *int64 `json:"id,omitempty"` - Key *string `json:"key,omitempty"` - URL *string `json:"url,omitempty"` - Title *string `json:"title,omitempty"` - ReadOnly *bool `json:"read_only,omitempty"` + ID *int64 `json:"id,omitempty"` + Key *string `json:"key,omitempty"` + URL *string `json:"url,omitempty"` + Title *string `json:"title,omitempty"` + ReadOnly *bool `json:"read_only,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` } func (k Key) String() string { From e98736d25359762a8652bb1f2b13bdb68ccd8b7f Mon Sep 17 00:00:00 2001 From: Szymon Kodrebski Date: Tue, 20 Aug 2019 17:21:22 +0200 Subject: [PATCH 2/3] Add missing field in users_keys class --- github/github-accessors.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 7c89cb60d0b..dfed8203162 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4612,6 +4612,14 @@ func (i *IssueStats) GetTotalIssues() int { return *i.TotalIssues } +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (k *Key) GetCreatedAt() time.Time { + if k == nil || k.CreatedAt == nil { + return time.Time{} + } + return *k.CreatedAt +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (k *Key) GetID() int64 { if k == nil || k.ID == nil { From 4465776b73918fee84fb171c98e855e3c59a6e91 Mon Sep 17 00:00:00 2001 From: Szymon Kodrebski Date: Wed, 21 Aug 2019 10:32:12 +0200 Subject: [PATCH 3/3] Changed type of field to Timestamp --- github/github-accessors.go | 4 ++-- github/github-stringify_test.go | 13 +++++++------ github/users_keys.go | 3 +-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index dfed8203162..434cc938c62 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -4613,9 +4613,9 @@ func (i *IssueStats) GetTotalIssues() int { } // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (k *Key) GetCreatedAt() time.Time { +func (k *Key) GetCreatedAt() Timestamp { if k == nil || k.CreatedAt == nil { - return time.Time{} + return Timestamp{} } return *k.CreatedAt } diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index c91f7b5a277..2e7b285ea0e 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -623,13 +623,14 @@ func TestIssueStats_String(t *testing.T) { func TestKey_String(t *testing.T) { v := Key{ - ID: Int64(0), - Key: String(""), - URL: String(""), - Title: String(""), - ReadOnly: Bool(false), + ID: Int64(0), + Key: String(""), + URL: String(""), + Title: String(""), + ReadOnly: Bool(false), + CreatedAt: &Timestamp{}, } - want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false}` + want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` if got := v.String(); got != want { t.Errorf("Key.String = %v, want %v", got, want) } diff --git a/github/users_keys.go b/github/users_keys.go index bb3d0402dfa..39a4f54d6c2 100644 --- a/github/users_keys.go +++ b/github/users_keys.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "time" ) // Key represents a public SSH key used to authenticate a user or deploy script. @@ -18,7 +17,7 @@ type Key struct { URL *string `json:"url,omitempty"` Title *string `json:"title,omitempty"` ReadOnly *bool `json:"read_only,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` } func (k Key) String() string {