Repository: google/go-github
Pull request #3344 (2024-11-06 21:16:05)

feat(secret scanning): Support `pull_request_comment_url`
Modify `SecretScanningAlertLocationDetails` to recognize API responses of type `pull_request_comment_url`.

Per the documentation available here:
https://docs.github.com/en/rest/secret-scanning/secret-scanning?apiVersion=2022-11-28

For requests to this route:
```
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/secret-scanning/alerts/ALERT_NUMBER/locations
  ```
  
  The API may return JSON that matches the following shape:
  ```javascript
  // ...
    {
    "type": "pull_request_comment",
    "details": {
      "pull_request_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments/1825855898"
    }
  },
  // ...
  ```
  
  (I'm sorry I can't provide a more specific link. The docs don't make one available.)
  
  Previously, `go-github` would not expose that data to the user. This change makes it available by adding a new field (`PullRequestCommentURL`) to the `SecretScanningAlertLocationDetails` struct.
  
  Tests are included.

google-cla[bot]: Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/google/go-github/pull/3344/checks?check_run_id=32621779969) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
chrisallenlane: If someone is able to re-run the `cla/google` check, I have signed the CLA. Thanks.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3344?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 92.30%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`4a031cd`)](https://app.codecov.io/gh/google/go-github/commit/4a031cd56f4f97d7f318eef3234e538c7975c361?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 165 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3344      +/-   ##
==========================================
- Coverage   97.72%   92.30%   -5.42%     
==========================================
  Files         153      176      +23     
  Lines       13390    15031    +1641     
==========================================
+ Hits        13085    13874     +789     
- Misses        215     1064     +849     
- Partials       90       93       +3     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3344?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-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 acc54e7d..1eb787dd 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -22958,6 +22958,14 @@ func (s *SecretScanningAlertLocationDetails) GetPath() string {
 	return *s.Path
 }
 
+// GetPullRequestCommentURL returns the PullRequestCommentURL field if it's non-nil, zero value otherwise.
+func (s *SecretScanningAlertLocationDetails) GetPullRequestCommentURL() string {
+	if s == nil || s.PullRequestCommentURL == nil {
+		return ""
+	}
+	return *s.PullRequestCommentURL
+}
+
 // GetStartColumn returns the StartColumn field if it's non-nil, zero value otherwise.
 func (s *SecretScanningAlertLocationDetails) GetStartColumn() int {
 	if s == nil || s.StartColumn == nil {
diff --git a/github/secret_scanning.go b/github/secret_scanning.go
index 9b2ad8cd..27449262 100644
--- a/github/secret_scanning.go
+++ b/github/secret_scanning.go
@@ -44,15 +44,16 @@ type SecretScanningAlertLocation struct {
 
 // SecretScanningAlertLocationDetails represents the location details for a secret scanning alert.
 type SecretScanningAlertLocationDetails struct {
-	Path        *string `json:"path,omitempty"`
-	Startline   *int    `json:"start_line,omitempty"`
-	EndLine     *int    `json:"end_line,omitempty"`
-	StartColumn *int    `json:"start_column,omitempty"`
-	EndColumn   *int    `json:"end_column,omitempty"`
-	BlobSHA     *string `json:"blob_sha,omitempty"`
-	BlobURL     *string `json:"blob_url,omitempty"`
-	CommitSHA   *string `json:"commit_sha,omitempty"`
-	CommitURL   *string `json:"commit_url,omitempty"`
+	Path                  *string `json:"path,omitempty"`
+	Startline             *int    `json:"start_line,omitempty"`
+	EndLine               *int    `json:"end_line,omitempty"`
+	StartColumn           *int    `json:"start_column,omitempty"`
+	EndColumn             *int    `json:"end_column,omitempty"`
+	BlobSHA               *string `json:"blob_sha,omitempty"`
+	BlobURL               *string `json:"blob_url,omitempty"`
+	CommitSHA             *string `json:"commit_sha,omitempty"`
+	CommitURL             *string `json:"commit_url,omitempty"`
+	PullRequestCommentURL *string `json:"pull_request_comment_url,omitempty"`
 }
 
 // SecretScanningAlertListOptions specifies optional parameters to the SecretScanningService.ListAlertsForEnterprise method.


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index eea6da94..b5c0d178 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -29433,6 +29433,17 @@ func TestSecretScanningAlertLocationDetails_GetPath(tt *testing.T) {
 	s.GetPath()
 }
 
+func TestSecretScanningAlertLocationDetails_GetPullRequestCommentURL(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	s := &SecretScanningAlertLocationDetails{PullRequestCommentURL: &zeroValue}
+	s.GetPullRequestCommentURL()
+	s = &SecretScanningAlertLocationDetails{}
+	s.GetPullRequestCommentURL()
+	s = nil
+	s.GetPullRequestCommentURL()
+}
+
 func TestSecretScanningAlertLocationDetails_GetStartColumn(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue int