Skip to content

Commit 10669e6

Browse files
authored
Additional options name, default_branch_only for create a fork (#2448)
Fixes: #2447.
1 parent 243bda8 commit 10669e6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

github/repos_forks.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string,
5353
// RepositoriesService.CreateFork method.
5454
type RepositoryCreateForkOptions struct {
5555
// The organization to fork the repository into.
56-
Organization string `url:"organization,omitempty"`
56+
Organization string `url:"organization,omitempty"`
57+
Name string `url:"name,omitempty"`
58+
DefaultBranchOnly bool `url:"default_branch_only,omitempty"`
5759
}
5860

5961
// CreateFork creates a fork of the specified repository.

github/repos_forks_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ func TestRepositoriesService_CreateFork(t *testing.T) {
7373

7474
mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) {
7575
testMethod(t, r, "POST")
76-
testFormValues(t, r, values{"organization": "o"})
76+
testFormValues(t, r, values{"organization": "o", "name": "n", "default_branch_only": "true"})
7777
fmt.Fprint(w, `{"id":1}`)
7878
})
7979

80-
opt := &RepositoryCreateForkOptions{Organization: "o"}
80+
opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true}
8181
ctx := context.Background()
8282
repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt)
8383
if err != nil {
@@ -110,13 +110,13 @@ func TestRepositoriesService_CreateFork_deferred(t *testing.T) {
110110

111111
mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) {
112112
testMethod(t, r, "POST")
113-
testFormValues(t, r, values{"organization": "o"})
113+
testFormValues(t, r, values{"organization": "o", "name": "n", "default_branch_only": "true"})
114114
// This response indicates the fork will happen asynchronously.
115115
w.WriteHeader(http.StatusAccepted)
116116
fmt.Fprint(w, `{"id":1}`)
117117
})
118118

119-
opt := &RepositoryCreateForkOptions{Organization: "o"}
119+
opt := &RepositoryCreateForkOptions{Organization: "o", Name: "n", DefaultBranchOnly: true}
120120
ctx := context.Background()
121121
repo, _, err := client.Repositories.CreateFork(ctx, "o", "r", opt)
122122
if _, ok := err.(*AcceptedError); !ok {

0 commit comments

Comments
 (0)