@@ -10,7 +10,6 @@ import (
1010 "strings"
1111 "time"
1212
13- "github.com/cli/cli/internal/ghinstance"
1413 "github.com/cli/cli/internal/ghrepo"
1514 "github.com/shurcooL/githubv4"
1615)
@@ -110,7 +109,7 @@ func GitHubRepo(client *Client, repo ghrepo.Interface) (*Repository, error) {
110109 return nil , err
111110 }
112111
113- return initRepoHostname (& result .Repository , repo .RepoHost ()), nil
112+ return InitRepoHostname (& result .Repository , repo .RepoHost ()), nil
114113}
115114
116115func RepoDefaultBranch (client * Client , repo ghrepo.Interface ) (string , error ) {
@@ -251,15 +250,15 @@ func RepoNetwork(client *Client, repos []ghrepo.Interface) (RepoNetworkResult, e
251250 if err := decoder .Decode (& repo ); err != nil {
252251 return result , err
253252 }
254- result .Repositories = append (result .Repositories , initRepoHostname (& repo , hostname ))
253+ result .Repositories = append (result .Repositories , InitRepoHostname (& repo , hostname ))
255254 } else {
256255 return result , fmt .Errorf ("unknown GraphQL result key %q" , name )
257256 }
258257 }
259258 return result , nil
260259}
261260
262- func initRepoHostname (repo * Repository , hostname string ) * Repository {
261+ func InitRepoHostname (repo * Repository , hostname string ) * Repository {
263262 repo .hostname = hostname
264263 if repo .Parent != nil {
265264 repo .Parent .hostname = hostname
@@ -339,74 +338,11 @@ func RepoFindFork(client *Client, repo ghrepo.Interface) (*Repository, error) {
339338 // `affiliations` condition, to guard against versions of GitHub with a
340339 // faulty `affiliations` implementation
341340 if len (forks ) > 0 && forks [0 ].ViewerCanPush () {
342- return initRepoHostname (& forks [0 ], repo .RepoHost ()), nil
341+ return InitRepoHostname (& forks [0 ], repo .RepoHost ()), nil
343342 }
344343 return nil , & NotFoundError {errors .New ("no fork found" )}
345344}
346345
347- // RepoCreateInput represents input parameters for RepoCreate
348- type RepoCreateInput struct {
349- Name string `json:"name"`
350- Visibility string `json:"visibility"`
351- HomepageURL string `json:"homepageUrl,omitempty"`
352- Description string `json:"description,omitempty"`
353-
354- OwnerID string `json:"ownerId,omitempty"`
355- TeamID string `json:"teamId,omitempty"`
356-
357- HasIssuesEnabled bool `json:"hasIssuesEnabled"`
358- HasWikiEnabled bool `json:"hasWikiEnabled"`
359- }
360-
361- // RepoCreate creates a new GitHub repository
362- func RepoCreate (client * Client , input RepoCreateInput ) (* Repository , error ) {
363- var response struct {
364- CreateRepository struct {
365- Repository Repository
366- }
367- }
368-
369- if input .TeamID != "" {
370- orgID , teamID , err := resolveOrganizationTeam (client , input .OwnerID , input .TeamID )
371- if err != nil {
372- return nil , err
373- }
374- input .TeamID = teamID
375- input .OwnerID = orgID
376- } else if input .OwnerID != "" {
377- orgID , err := resolveOrganization (client , input .OwnerID )
378- if err != nil {
379- return nil , err
380- }
381- input .OwnerID = orgID
382- }
383-
384- variables := map [string ]interface {}{
385- "input" : input ,
386- }
387-
388- // TODO: GHE support
389- hostname := ghinstance .Default ()
390-
391- err := client .GraphQL (hostname , `
392- mutation RepositoryCreate($input: CreateRepositoryInput!) {
393- createRepository(input: $input) {
394- repository {
395- id
396- name
397- owner { login }
398- url
399- }
400- }
401- }
402- ` , variables , & response )
403- if err != nil {
404- return nil , err
405- }
406-
407- return initRepoHostname (& response .CreateRepository .Repository , hostname ), nil
408- }
409-
410346type RepoMetadataResult struct {
411347 AssignableUsers []RepoAssignee
412348 Labels []RepoLabel
0 commit comments