@@ -21,9 +21,9 @@ type ListOptions struct {
2121
2222type CreateOptions struct {
2323 AccessToken string
24- Name string
24+ Name string
2525 Description string
26- Private bool
26+ Private bool
2727}
2828
2929func NewDefaultListOptions () * ListOptions {
@@ -41,33 +41,26 @@ func NewDefaultListOptions() *ListOptions {
4141 return & opts
4242}
4343
44- // CreateRepo is a helper method for creating a new
44+ // CreateRepo is a helper method for creating a new
4545func CreateRepo (org_name string , opts * CreateOptions ) error {
4646
47-
4847 // https://docs.github.com/en/rest/reference/repos#create-an-organization-repository
4948 // https://github.com/google/go-github/blob/v17.0.0/example/newrepo/main.go
49+ // https://github.com/google/go-github/blob/v17.0.0/github/repos.go#L262
5050
5151 client , ctx , err := util .NewClientAndContext (opts .AccessToken )
5252
5353 if err != nil {
5454 return fmt .Errorf ("Failed to create new client, %w" , err )
5555 }
5656
57- org , _ , err := client .Organizations .Get (ctx , org_name )
58-
59- if err != nil {
60- return fmt .Errorf ("Failed to retrieve organization, %w" , err )
61- }
62-
6357 r := & github.Repository {
64- Name : & opts .Name ,
65- Private : & opts .Private ,
58+ Name : & opts .Name ,
59+ Private : & opts .Private ,
6660 Description : & opts .Description ,
67- Organization : org ,
6861 }
69-
70- _ , _ , err = client .Repositories .Create (ctx , "" , r )
62+
63+ _ , _ , err = client .Repositories .Create (ctx , org_name , r )
7164
7265 if err != nil {
7366 return fmt .Errorf ("Failed to create repository, %w" , err )
0 commit comments