Repository: google/go-github
Pull request #1795 (2021-02-05 11:46:08)

Repository.ListByOrg: Add nebula-preview to receive visibility field
**What type of PR is this?**

feature

**What this PR does / why we need it:**

In addition to the changes added in https://github.com/google/go-github/pull/1780, this change also ensures the `Visibility` field is included when calling `Repositories.ListByOrg`.

**Special notes for your reviewer:**

None

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

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed (or fixed any issues), please reply here with `@googlebot I signed it!` and we'll verify it.

----

#### What to do if you already signed the CLA

##### Individual signers

*   It's possible we don't have your GitHub username or you're using a different email address on your commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).

##### Corporate signers

*   Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to [go/cla#troubleshoot](http://go/cla#troubleshoot) ([Public version](https://opensource.google/docs/cla/#troubleshoot)).
*   The email used to register you as an authorized contributor must be the email used for the Git commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
*   The email used to register you as an authorized contributor must also be [attached to your GitHub account](https://github.com/settings/emails).
		

ℹ️ **Googlers: [Go here](https://goto.google.com/prinfo/https%3A%2F%2Fgithub.com%2Fgoogle%2Fgo-github%2Fpull%2F1795) for more info**.

<!-- need_sender_cla -->
marcelocarlos: @googlebot I signed it!
codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=h1) Report
> Merging [#1795](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=desc) (22cb4f1) into [master](https://codecov.io/gh/google/go-github/commit/24b281b68b92592641a91a99ebde3c362720951d?el=desc) (24b281b) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1795/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1795   +/-   ##
=======================================
  Coverage   97.54%   97.54%           
=======================================
  Files          98       98           
  Lines        6383     6383           
=======================================
  Hits         6226     6226           
  Misses         85       85           
  Partials       72       72           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/repos.go](https://codecov.io/gh/google/go-github/pull/1795/diff?src=pr&el=tree#diff-Z2l0aHViL3JlcG9zLmdv) | `98.70% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=footer). Last update [24b281b...22cb4f1](https://codecov.io/gh/google/go-github/pull/1795?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/repos.go b/github/repos.go
index 22c0f8fa..989f2756 100644
--- a/github/repos.go
+++ b/github/repos.go
@@ -248,7 +248,7 @@ func (s *RepositoriesService) ListByOrg(ctx context.Context, org string, opts *R
 	}
 
 	// TODO: remove custom Accept headers when APIs fully launch.
-	acceptHeaders := []string{mediaTypeTopicsPreview}
+	acceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview}
 	req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
 
 	var repos []*Repository


Test patch:
diff --git a/github/repos_test.go b/github/repos_test.go
index bbe82ea6..192378ea 100644
--- a/github/repos_test.go
+++ b/github/repos_test.go
@@ -131,7 +131,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	wantAcceptHeaders := []string{mediaTypeTopicsPreview}
+	wantAcceptHeaders := []string{mediaTypeTopicsPreview, mediaTypeRepositoryVisibilityPreview}
 	mux.HandleFunc("/orgs/o/repos", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, "GET")
 		testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))