Repository: google/go-github (Go)

Issue:
Add MergedAt field to PullRequestLinks
Please add MergedAt field to PullRequestLinks.
github upstream schema now has merged_at field:

```json
      "pull_request": {
        "type": "object",
        "properties": {
          "merged_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          ...
```

Primary use case for this field is to know whether closed pull request is merged or not if API response returns Issues rather than PullRequests (e.g., search API).



Discussion:

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 256bfacfb50..6663fc1ae7d 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -16262,6 +16262,14 @@ func (p *PullRequestLinks) GetHTMLURL() string {
 	return *p.HTMLURL
 }
 
+// GetMergedAt returns the MergedAt field if it's non-nil, zero value otherwise.
+func (p *PullRequestLinks) GetMergedAt() Timestamp {
+	if p == nil || p.MergedAt == nil {
+		return Timestamp{}
+	}
+	return *p.MergedAt
+}
+
 // GetPatchURL returns the PatchURL field if it's non-nil, zero value otherwise.
 func (p *PullRequestLinks) GetPatchURL() string {
 	if p == nil || p.PatchURL == nil {
diff --git a/github/issues.go b/github/issues.go
index 1c07fef827b..a2652b34972 100644
--- a/github/issues.go
+++ b/github/issues.go
@@ -122,10 +122,11 @@ type IssueListOptions struct {
 // PullRequestLinks object is added to the Issue object when it's an issue included
 // in the IssueCommentEvent webhook payload, if the webhook is fired by a comment on a PR.
 type PullRequestLinks struct {
-	URL      *string `json:"url,omitempty"`
-	HTMLURL  *string `json:"html_url,omitempty"`
-	DiffURL  *string `json:"diff_url,omitempty"`
-	PatchURL *string `json:"patch_url,omitempty"`
+	URL      *string    `json:"url,omitempty"`
+	HTMLURL  *string    `json:"html_url,omitempty"`
+	DiffURL  *string    `json:"diff_url,omitempty"`
+	PatchURL *string    `json:"patch_url,omitempty"`
+	MergedAt *Timestamp `json:"merged_at,omitempty"`
 }
 
 // List the issues for the authenticated user. If all is true, list issues


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 461ce8ed7eb..86c9140d55b 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -18864,6 +18864,16 @@ func TestPullRequestLinks_GetHTMLURL(tt *testing.T) {
 	p.GetHTMLURL()
 }
 
+func TestPullRequestLinks_GetMergedAt(tt *testing.T) {
+	var zeroValue Timestamp
+	p := &PullRequestLinks{MergedAt: &zeroValue}
+	p.GetMergedAt()
+	p = &PullRequestLinks{}
+	p.GetMergedAt()
+	p = nil
+	p.GetMergedAt()
+}
+
 func TestPullRequestLinks_GetPatchURL(tt *testing.T) {
 	var zeroValue string
 	p := &PullRequestLinks{PatchURL: &zeroValue}
diff --git a/github/issues_test.go b/github/issues_test.go
index aa767d6508a..d64ef88d72f 100644
--- a/github/issues_test.go
+++ b/github/issues_test.go
@@ -499,13 +499,15 @@ func TestPullRequestLinks_Marshal(t *testing.T) {
 		HTMLURL:  String("hurl"),
 		DiffURL:  String("durl"),
 		PatchURL: String("purl"),
+		MergedAt: &Timestamp{referenceTime},
 	}
 
 	want := `{
 		"url": "url",
 		"html_url": "hurl",
 		"diff_url": "durl",
-		"patch_url": "purl"
+		"patch_url": "purl",
+		"merged_at": ` + referenceTimeStr + `
 		}`
 
 	testJSONMarshal(t, u, want)