Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional options name, default_branch_only for create a fork #2448

Merged
merged 2 commits into from Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion github/repos_forks.go
Expand Up @@ -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"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name string `url:"name,omitempty"`
DefaultBranchOnly bool `url:"default_branch_only,omitempty"`
}

// CreateFork creates a fork of the specified repository.
Expand Down
8 changes: 4 additions & 4 deletions github/repos_forks_test.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down