Repository: google/go-github
Pull request #2743 (2023-04-08 09:45:12)

Add GetTime method to Timestamp
add a small handy helper func

codecov[bot]: ## [Codecov](https://codecov.io/gh/google/go-github/pull/2743?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2743](https://codecov.io/gh/google/go-github/pull/2743?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (3686f2d) into [master](https://codecov.io/gh/google/go-github/commit/4fec23d72f617c085ce35204eb9bd484bf4a2b93?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (4fec23d) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master    #2743   +/-   ##
=======================================
  Coverage   98.05%   98.05%           
=======================================
  Files         132      132           
  Lines       11611    11616    +5     
=======================================
+ Hits        11385    11390    +5     
  Misses        154      154           
  Partials       72       72           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2743?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/timestamp.go](https://codecov.io/gh/google/go-github/pull/2743?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL3RpbWVzdGFtcC5nbw==) | `100.00% <100.00%> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 92a952ef..ae6e2867 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -13046,6 +13046,14 @@ func (p *Protection) GetRequiredPullRequestReviews() *PullRequestReviewsEnforcem
 	return p.RequiredPullRequestReviews
 }
 
+// GetRequiredSignatures returns the RequiredSignatures field.
+func (p *Protection) GetRequiredSignatures() *SignaturesProtectedBranch {
+	if p == nil {
+		return nil
+	}
+	return p.RequiredSignatures
+}
+
 // GetRequiredStatusChecks returns the RequiredStatusChecks field.
 func (p *Protection) GetRequiredStatusChecks() *RequiredStatusChecks {
 	if p == nil {
@@ -13070,6 +13078,14 @@ func (p *Protection) GetRestrictions() *BranchRestrictions {
 	return p.Restrictions
 }
 
+// GetURL returns the URL field if it's non-nil, zero value otherwise.
+func (p *Protection) GetURL() string {
+	if p == nil || p.URL == nil {
+		return ""
+	}
+	return *p.URL
+}
+
 // GetAdminEnforced returns the AdminEnforced field.
 func (p *ProtectionChanges) GetAdminEnforced() *AdminEnforcedChanges {
 	if p == nil {
@@ -17718,6 +17734,22 @@ func (r *RequiredStatusCheck) GetAppID() int64 {
 	return *r.AppID
 }
 
+// GetContextsURL returns the ContextsURL field if it's non-nil, zero value otherwise.
+func (r *RequiredStatusChecks) GetContextsURL() string {
+	if r == nil || r.ContextsURL == nil {
+		return ""
+	}
+	return *r.ContextsURL
+}
+
+// GetURL returns the URL field if it's non-nil, zero value otherwise.
+func (r *RequiredStatusChecks) GetURL() string {
+	if r == nil || r.URL == nil {
+		return ""
+	}
+	return *r.URL
+}
+
 // GetFrom returns the From field if it's non-nil, zero value otherwise.
 func (r *RequiredStatusChecksEnforcementLevelChanges) GetFrom() string {
 	if r == nil || r.From == nil {
diff --git a/github/repos.go b/github/repos.go
index fad152e2..9c9c7506 100644
--- a/github/repos.go
+++ b/github/repos.go
@@ -847,6 +847,8 @@ type Protection struct {
 	BlockCreations                 *BlockCreations                 `json:"block_creations,omitempty"`
 	LockBranch                     *LockBranch                     `json:"lock_branch,omitempty"`
 	AllowForkSyncing               *AllowForkSyncing               `json:"allow_fork_syncing,omitempty"`
+	RequiredSignatures             *SignaturesProtectedBranch      `json:"required_signatures,omitempty"`
+	URL                            *string                         `json:"url,omitempty"`
 }
 
 // BlockCreations represents whether users can push changes that create branches. If this is true, this
@@ -1023,7 +1025,9 @@ type RequiredStatusChecks struct {
 	Contexts []string `json:"contexts,omitempty"`
 	// The list of status checks to require in order to merge into this
 	// branch.
-	Checks []*RequiredStatusCheck `json:"checks"`
+	Checks      []*RequiredStatusCheck `json:"checks"`
+	ContextsURL *string                `json:"contexts_url,omitempty"`
+	URL         *string                `json:"url,omitempty"`
 }
 
 // RequiredStatusChecksRequest represents a request to edit a protected branch's status checks.
diff --git a/github/timestamp.go b/github/timestamp.go
index 1061a55e..00c1235e 100644
--- a/github/timestamp.go
+++ b/github/timestamp.go
@@ -22,6 +22,14 @@ func (t Timestamp) String() string {
 	return t.Time.String()
 }
 
+// GetTime returns std time.Time.
+func (t *Timestamp) GetTime() *time.Time {
+	if t == nil {
+		return nil
+	}
+	return &t.Time
+}
+
 // UnmarshalJSON implements the json.Unmarshaler interface.
 // Time is expected in RFC3339 or Unix format.
 func (t *Timestamp) UnmarshalJSON(data []byte) (err error) {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index fae13c0e..487104fb 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -15237,6 +15237,13 @@ func TestProtection_GetRequiredPullRequestReviews(tt *testing.T) {
 	p.GetRequiredPullRequestReviews()
 }
 
+func TestProtection_GetRequiredSignatures(tt *testing.T) {
+	p := &Protection{}
+	p.GetRequiredSignatures()
+	p = nil
+	p.GetRequiredSignatures()
+}
+
 func TestProtection_GetRequiredStatusChecks(tt *testing.T) {
 	p := &Protection{}
 	p.GetRequiredStatusChecks()
@@ -15258,6 +15265,16 @@ func TestProtection_GetRestrictions(tt *testing.T) {
 	p.GetRestrictions()
 }
 
+func TestProtection_GetURL(tt *testing.T) {
+	var zeroValue string
+	p := &Protection{URL: &zeroValue}
+	p.GetURL()
+	p = &Protection{}
+	p.GetURL()
+	p = nil
+	p.GetURL()
+}
+
 func TestProtectionChanges_GetAdminEnforced(tt *testing.T) {
 	p := &ProtectionChanges{}
 	p.GetAdminEnforced()
@@ -20639,6 +20656,26 @@ func TestRequiredStatusCheck_GetAppID(tt *testing.T) {
 	r.GetAppID()
 }
 
+func TestRequiredStatusChecks_GetContextsURL(tt *testing.T) {
+	var zeroValue string
+	r := &RequiredStatusChecks{ContextsURL: &zeroValue}
+	r.GetContextsURL()
+	r = &RequiredStatusChecks{}
+	r.GetContextsURL()
+	r = nil
+	r.GetContextsURL()
+}
+
+func TestRequiredStatusChecks_GetURL(tt *testing.T) {
+	var zeroValue string
+	r := &RequiredStatusChecks{URL: &zeroValue}
+	r.GetURL()
+	r = &RequiredStatusChecks{}
+	r.GetURL()
+	r = nil
+	r.GetURL()
+}
+
 func TestRequiredStatusChecksEnforcementLevelChanges_GetFrom(tt *testing.T) {
 	var zeroValue string
 	r := &RequiredStatusChecksEnforcementLevelChanges{From: &zeroValue}
diff --git a/github/timestamp_test.go b/github/timestamp_test.go
index 09724951..69245b60 100644
--- a/github/timestamp_test.go
+++ b/github/timestamp_test.go
@@ -169,6 +169,17 @@ func TestWrappedTimestamp_Unmarshal(t *testing.T) {
 	}
 }
 
+func TestTimestamp_GetTime(t *testing.T) {
+	var t1 *Timestamp
+	if t1.GetTime() != nil {
+		t.Errorf("nil timestamp should return nil, got: %v", t1.GetTime())
+	}
+	t1 = &Timestamp{referenceTime}
+	if !t1.GetTime().Equal(referenceTime) {
+		t.Errorf("want reference time, got: %s", t1.GetTime().String())
+	}
+}
+
 func TestWrappedTimestamp_MarshalReflexivity(t *testing.T) {
 	testCases := []struct {
 		desc string