Repository: google/go-github
Pull request #2822 (2023-06-28 20:16:45)

Fix ListPullRequestsWithCommit option type
`ListPullRequestsWithCommit` uses `PullRequestListOptions` as one of it's parameters. This is incorrect because in GitHub's documentation, the endpoint for this function, `repos/%v/%v/commits/%v/pulls`, does not share the same parameters as the ones defined in `ListPullRequestsWithCommit`

https://github.com/google/go-github/blob/96726d8192f34c0d46e7b64b3c400962e8e64898/github/pulls.go#L119-L141

![image](https://github.com/google/go-github/assets/33658638/7d30c9a8-fbe5-45ad-9dae-b682e9884ea9)

This PR simply sets the correct options, ListOptions, for the ListPullRequestWithCommit.


see #2815  for more details


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 01b5796f..41cd582c 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -19510,6 +19510,14 @@ func (s *SecretScanningAlert) GetNumber() int {
 	return *s.Number
 }
 
+// GetRepository returns the Repository field.
+func (s *SecretScanningAlert) GetRepository() *Repository {
+	if s == nil {
+		return nil
+	}
+	return s.Repository
+}
+
 // GetResolution returns the Resolution field if it's non-nil, zero value otherwise.
 func (s *SecretScanningAlert) GetResolution() string {
 	if s == nil || s.Resolution == nil {
diff --git a/github/pulls.go b/github/pulls.go
index 6e49eba2..533e86b5 100644
--- a/github/pulls.go
+++ b/github/pulls.go
@@ -170,7 +170,7 @@ func (s *PullRequestsService) List(ctx context.Context, owner string, repo strin
 // By default, the PullRequestListOptions State filters for "open".
 //
 // GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-pull-requests-associated-with-a-commit
-func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) {
+func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *ListOptions) ([]*PullRequest, *Response, error) {
 	u := fmt.Sprintf("repos/%v/%v/commits/%v/pulls", owner, repo, sha)
 	u, err := addOptions(u, opts)
 	if err != nil {
diff --git a/github/secret_scanning.go b/github/secret_scanning.go
index d512560d..36ad5553 100644
--- a/github/secret_scanning.go
+++ b/github/secret_scanning.go
@@ -16,17 +16,18 @@ type SecretScanningService service
 
 // SecretScanningAlert represents a GitHub secret scanning alert.
 type SecretScanningAlert struct {
-	Number       *int       `json:"number,omitempty"`
-	CreatedAt    *Timestamp `json:"created_at,omitempty"`
-	URL          *string    `json:"url,omitempty"`
-	HTMLURL      *string    `json:"html_url,omitempty"`
-	LocationsURL *string    `json:"locations_url,omitempty"`
-	State        *string    `json:"state,omitempty"`
-	Resolution   *string    `json:"resolution,omitempty"`
-	ResolvedAt   *Timestamp `json:"resolved_at,omitempty"`
-	ResolvedBy   *User      `json:"resolved_by,omitempty"`
-	SecretType   *string    `json:"secret_type,omitempty"`
-	Secret       *string    `json:"secret,omitempty"`
+	Number       *int        `json:"number,omitempty"`
+	CreatedAt    *Timestamp  `json:"created_at,omitempty"`
+	URL          *string     `json:"url,omitempty"`
+	HTMLURL      *string     `json:"html_url,omitempty"`
+	LocationsURL *string     `json:"locations_url,omitempty"`
+	State        *string     `json:"state,omitempty"`
+	Resolution   *string     `json:"resolution,omitempty"`
+	ResolvedAt   *Timestamp  `json:"resolved_at,omitempty"`
+	ResolvedBy   *User       `json:"resolved_by,omitempty"`
+	SecretType   *string     `json:"secret_type,omitempty"`
+	Secret       *string     `json:"secret,omitempty"`
+	Repository   *Repository `json:"repository,omitempty"`
 }
 
 // SecretScanningAlertLocation represents the location for a secret scanning alert.


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 959edc4d..993a1248 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -22792,6 +22792,13 @@ func TestSecretScanningAlert_GetNumber(tt *testing.T) {
 	s.GetNumber()
 }
 
+func TestSecretScanningAlert_GetRepository(tt *testing.T) {
+	s := &SecretScanningAlert{}
+	s.GetRepository()
+	s = nil
+	s.GetRepository()
+}
+
 func TestSecretScanningAlert_GetResolution(tt *testing.T) {
 	var zeroValue string
 	s := &SecretScanningAlert{Resolution: &zeroValue}
diff --git a/github/pulls_test.go b/github/pulls_test.go
index 590483fa..87f6f41c 100644
--- a/github/pulls_test.go
+++ b/github/pulls_test.go
@@ -69,17 +69,12 @@ func TestPullRequestsService_ListPullRequestsWithCommit(t *testing.T) {
 		testMethod(t, r, "GET")
 		testHeader(t, r, "Accept", mediaTypeListPullsOrBranchesForCommitPreview)
 		testFormValues(t, r, values{
-			"state":     "closed",
-			"head":      "h",
-			"base":      "b",
-			"sort":      "created",
-			"direction": "desc",
-			"page":      "2",
+			"page": "2",
 		})
 		fmt.Fprint(w, `[{"number":1}]`)
 	})
 
-	opts := &PullRequestListOptions{"closed", "h", "b", "created", "desc", ListOptions{Page: 2}}
+	opts := &ListOptions{Page: 2}
 	ctx := context.Background()
 	pulls, _, err := client.PullRequests.ListPullRequestsWithCommit(ctx, "o", "r", "sha", opts)
 	if err != nil {
diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go
index 69cd7d3f..75275913 100644
--- a/github/secret_scanning_test.go
+++ b/github/secret_scanning_test.go
@@ -35,7 +35,12 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) {
 			"resolved_at": null,
 			"resolved_by": null,
 			"secret_type": "mailchimp_api_key",
-			"secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"
+			"secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2",
+			"repository": {
+				"id": 1,
+				"name": "n",
+				"url": "url"
+			}
 		}]`)
 	})
 
@@ -61,6 +66,11 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) {
 			ResolvedBy:   nil,
 			SecretType:   String("mailchimp_api_key"),
 			Secret:       String("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us2"),
+			Repository: &Repository{
+				ID:   Int64(1),
+				URL:  String("url"),
+				Name: String("n"),
+			},
 		},
 	}