Repository: google/go-github
Pull request #2788 (2023-05-26 08:03:02)

Add "new_name" parameter to repo transfer request (#2787)
Resolves: https://github.com/google/go-github/issues/2787

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/2788/checks?check_run_id=13779988179) 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.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/2788?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2788](https://app.codecov.io/gh/google/go-github/pull/2788?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (86d7b92) into [master](https://app.codecov.io/gh/google/go-github/commit/f96b64ece988554ba6444cb305e6db1132a61454?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (f96b64e) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##           master    #2788   +/-   ##
=======================================
  Coverage   98.06%   98.06%           
=======================================
  Files         132      132           
  Lines       11650    11650           
=======================================
  Hits        11424    11424           
  Misses        154      154           
  Partials       72       72           
```


| [Impacted Files](https://app.codecov.io/gh/google/go-github/pull/2788?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/orgs\_audit\_log.go](https://app.codecov.io/gh/google/go-github/pull/2788?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL29yZ3NfYXVkaXRfbG9nLmdv) | `100.00% <ø> (ø)` | |
| [github/repos.go](https://app.codecov.io/gh/google/go-github/pull/2788?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL3JlcG9zLmdv) | `98.84% <ø> (ø)` | |


kgalli: @gmlewis thanks for the hint. I updated the code and run the generate command. Have to admit did not thought about the accessors. Very nice that you have generators in place for that.

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index f310e42a..c2d9061c 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -20862,6 +20862,14 @@ func (t *TrafficViews) GetUniques() int {
 	return *t.Uniques
 }
 
+// GetNewName returns the NewName field if it's non-nil, zero value otherwise.
+func (t *TransferRequest) GetNewName() string {
+	if t == nil || t.NewName == nil {
+		return ""
+	}
+	return *t.NewName
+}
+
 // GetSHA returns the SHA field if it's non-nil, zero value otherwise.
 func (t *Tree) GetSHA() string {
 	if t == nil || t.SHA == nil {
diff --git a/github/repos.go b/github/repos.go
index 9c9c7506..5ffad6dd 100644
--- a/github/repos.go
+++ b/github/repos.go
@@ -1969,6 +1969,7 @@ func (s *RepositoriesService) RemoveUserRestrictions(ctx context.Context, owner,
 // TransferRequest represents a request to transfer a repository.
 type TransferRequest struct {
 	NewOwner string  `json:"new_owner"`
+	NewName  *string `json:"new_name,omitempty"`
 	TeamID   []int64 `json:"team_ids,omitempty"`
 }
 


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 97f3994f..eb0a0db4 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -24329,6 +24329,16 @@ func TestTrafficViews_GetUniques(tt *testing.T) {
 	t.GetUniques()
 }
 
+func TestTransferRequest_GetNewName(tt *testing.T) {
+	var zeroValue string
+	t := &TransferRequest{NewName: &zeroValue}
+	t.GetNewName()
+	t = &TransferRequest{}
+	t.GetNewName()
+	t = nil
+	t.GetNewName()
+}
+
 func TestTree_GetSHA(tt *testing.T) {
 	var zeroValue string
 	t := &Tree{SHA: &zeroValue}
diff --git a/github/repos_test.go b/github/repos_test.go
index 992ec418..b35f44dd 100644
--- a/github/repos_test.go
+++ b/github/repos_test.go
@@ -3220,7 +3220,7 @@ func TestRepositoriesService_Transfer(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
 
-	input := TransferRequest{NewOwner: "a", TeamID: []int64{123}}
+	input := TransferRequest{NewOwner: "a", NewName: String("b"), TeamID: []int64{123}}
 
 	mux.HandleFunc("/repos/o/r/transfer", func(w http.ResponseWriter, r *http.Request) {
 		var v TransferRequest
@@ -3390,11 +3390,13 @@ func TestTransferRequest_Marshal(t *testing.T) {
 
 	u := &TransferRequest{
 		NewOwner: "testOwner",
+		NewName:  String("testName"),
 		TeamID:   []int64{1, 2},
 	}
 
 	want := `{
 		"new_owner": "testOwner",
+		"new_name": "testName",
 		"team_ids": [1,2]
 	}`