Disable wiki with template by utouto97 · Pull Request #7886 · cli/cli · GitHub
Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/cmd/repo/create/create.go
26 changes: 26 additions & 0 deletions pkg/cmd/repo/create/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ type cloneTemplateRepositoryInput struct {
IncludeAllBranches bool `json:"includeAllBranches"`
}

type updateRepositoryInput struct {
RepositoryID string `json:"repositoryId"`
HasWikiEnabled bool `json:"hasWikiEnabled"`
}

// repoCreate creates a new GitHub repository
func repoCreate(client *http.Client, hostname string, input repoCreateInput) (*api.Repository, error) {
isOrg := false
Expand Down Expand Up @@ -133,6 +138,27 @@ func repoCreate(client *http.Client, hostname string, input repoCreateInput) (*a
return nil, err
}

if !input.HasWikiEnabled {
updateVariables := map[string]interface{}{
"input": updateRepositoryInput{
RepositoryID: response.CloneTemplateRepository.Repository.ID,
HasWikiEnabled: input.HasWikiEnabled,
},
}

if err := apiClient.GraphQL(hostname, `
mutation UpdateRepository($input: UpdateRepositoryInput!) {
updateRepository(input: $input) {
repository {
id
}
}
}
`, updateVariables, nil); err != nil {
return nil, err
}
}

return api.InitRepoHostname(&response.CloneTemplateRepository.Repository, hostname), nil
}

Expand Down
64 changes: 64 additions & 0 deletions pkg/cmd/repo/create/http_test.go