Skip to content

Commit e461baa

Browse files
author
ulwlu
committed
Fix prompt string when creating remote repository
If you are in git project not pushed to remote yet, prompt says 'This will create {reponame} in current directory. Continue?', however, it doesn't create while it only adds remote origin. I was going to create PR to avoid creating new directory before I knew this behavior. This behavior is already ideal, so I changed prompt not to scare users like I got scared.
1 parent 4e5aa91 commit e461baa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/cmd/repo/create/create.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func createRun(opts *CreateOptions) error {
250250

251251
createLocalDirectory := opts.ConfirmSubmit
252252
if !opts.ConfirmSubmit {
253-
opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID)
253+
opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID, projectDirErr)
254254
if err != nil {
255255
return err
256256
}
@@ -388,11 +388,13 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s
388388
return answers.RepoName, answers.RepoDescription, strings.ToUpper(answers.RepoVisibility), nil
389389
}
390390

391-
func confirmSubmission(repoName string, repoOwner string) (bool, error) {
391+
func confirmSubmission(repoName string, repoOwner string, projectDirErr error) (bool, error) {
392392
qs := []*survey.Question{}
393393

394394
promptString := ""
395-
if repoOwner != "" {
395+
if projectDirErr == nil {
396+
promptString = fmt.Sprintf("This will add remote origin to your current directory. Continue? ")
397+
} else if repoOwner != "" {
396398
promptString = fmt.Sprintf("This will create '%s/%s' in your current directory. Continue? ", repoOwner, repoName)
397399
} else {
398400
promptString = fmt.Sprintf("This will create '%s' in your current directory. Continue? ", repoName)

0 commit comments

Comments
 (0)