@@ -111,29 +111,17 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
111111
112112func createRun (opts * CreateOptions ) error {
113113 projectDir , projectDirErr := git .ToplevelDir ()
114-
115- var repoToCreate ghrepo.Interface
116-
117114 isNameAnArg := false
118115 isDescEmpty := opts .Description == ""
119116 isVisibilityPassed := false
120117
121118 if opts .Name != "" {
122119 isNameAnArg = true
123- if strings .Contains (opts .Name , "/" ) {
124- var err error
125- repoToCreate , err = ghrepo .FromFullName (opts .Name )
126- if err != nil {
127- return fmt .Errorf ("argument error: %w" , err )
128- }
129- } else {
130- repoToCreate = ghrepo .New ("" , opts .Name )
131- }
132120 } else {
133121 if projectDirErr != nil {
134122 return projectDirErr
135123 }
136- repoToCreate = ghrepo . New ( "" , path .Base (projectDir ) )
124+ opts . Name = path .Base (projectDir )
137125 }
138126
139127 enabledFlagCount := 0
@@ -159,7 +147,7 @@ func createRun(opts *CreateOptions) error {
159147
160148 // Trigger interactive prompt if name is not passed
161149 if ! isNameAnArg {
162- newName , newDesc , newVisibility , err := interactiveRepoCreate (isDescEmpty , isVisibilityPassed , repoToCreate . RepoName () )
150+ newName , newDesc , newVisibility , err := interactiveRepoCreate (isDescEmpty , isVisibilityPassed , opts . Name )
163151 if err != nil {
164152 return err
165153 }
@@ -183,6 +171,18 @@ func createRun(opts *CreateOptions) error {
183171 }
184172 }
185173
174+ var repoToCreate ghrepo.Interface
175+
176+ if strings .Contains (opts .Name , "/" ) {
177+ var err error
178+ repoToCreate , err = ghrepo .FromFullName (opts .Name )
179+ if err != nil {
180+ return fmt .Errorf ("argument error: %w" , err )
181+ }
182+ } else {
183+ repoToCreate = ghrepo .New ("" , opts .Name )
184+ }
185+
186186 // Find template repo ID
187187 if opts .Template != "" {
188188 httpClient , err := opts .HttpClient ()
@@ -303,6 +303,7 @@ func createRun(opts *CreateOptions) error {
303303 fmt .Fprintf (stderr , "%s Initialized repository in './%s/'\n " , utils .GreenCheck (), path )
304304 }
305305 }
306+
306307 return nil
307308 }
308309 fmt .Fprintln (opts .IO .Out , "Discarding..." )
@@ -312,14 +313,14 @@ func createRun(opts *CreateOptions) error {
312313func interactiveRepoCreate (isDescEmpty bool , isVisibilityPassed bool , repoName string ) (string , string , string , error ) {
313314 qs := []* survey.Question {}
314315
315- repoOwnerQuestion := & survey.Question {
316- Name : "repoOwner " ,
316+ repoNameQuestion := & survey.Question {
317+ Name : "repoName " ,
317318 Prompt : & survey.Input {
318319 Message : "Repository name" ,
319320 Default : repoName ,
320321 },
321322 }
322- qs = append (qs , repoOwnerQuestion )
323+ qs = append (qs , repoNameQuestion )
323324
324325 if isDescEmpty {
325326 repoDescriptionQuestion := & survey.Question {
@@ -344,7 +345,7 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s
344345 }
345346
346347 answers := struct {
347- RepoOwner string
348+ RepoName string
348349 RepoDescription string
349350 RepoVisibility string
350351 }{}
@@ -355,8 +356,7 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s
355356 return "" , "" , "" , err
356357 }
357358
358- return answers .RepoOwner , answers .RepoDescription , strings .ToUpper (answers .RepoVisibility ), nil
359-
359+ return answers .RepoName , answers .RepoDescription , strings .ToUpper (answers .RepoVisibility ), nil
360360}
361361
362362func confirmSubmission (repoName string , repoOwner string , isConfirmFlagPassed * bool ) (bool , error ) {
0 commit comments