diff --git a/github/repos_forks.go b/github/repos_forks.go index 97bb328ffb..5c7d5dbd78 100644 --- a/github/repos_forks.go +++ b/github/repos_forks.go @@ -53,7 +53,9 @@ func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, // RepositoriesService.CreateFork method. type RepositoryCreateForkOptions struct { // The organization to fork the repository into. - Organization string `url:"organization,omitempty"` + Organization string `url:"organization,omitempty"` + Name string `url:"name,omitempty"` + DefaultBranchOnly bool `url:"default_branch_only,omitempty"` } // CreateFork creates a fork of the specified repository. diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index 83b7a82781..07be423bc3 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -73,11 +73,11 @@ func TestRepositoriesService_CreateFork(t *testing.T) { mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testFormValues(t, r, values{"organization": "o"}) + testFormValues(t, r, values{"organization": "o", "name": "n", "default_branch_only": "true"}) fmt.Fprint(w, `{"id":1}`) }) - opt := &RepositoryCreateForkOptions{Organization: "o"} + opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true} ctx := context.Background() repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt) if err != nil { @@ -110,13 +110,13 @@ func TestRepositoriesService_CreateFork_deferred(t *testing.T) { mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - testFormValues(t, r, values{"organization": "o"}) + testFormValues(t, r, values{"organization": "o", "name": "n", "default_branch_only": "true"}) // This response indicates the fork will happen asynchronously. w.WriteHeader(http.StatusAccepted) fmt.Fprint(w, `{"id":1}`) }) - opt := &RepositoryCreateForkOptions{Organization: "o"} + opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true} ctx := context.Background() repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt) if _, ok := err.(*AcceptedError); !ok {