From e461baa217f7ea3f723460e8ff4b8ab17443841b Mon Sep 17 00:00:00 2001 From: ulwlu Date: Sat, 13 Feb 2021 17:11:08 +0900 Subject: [PATCH] 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. --- pkg/cmd/repo/create/create.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 2b1c1f088..11007f40c 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -250,7 +250,7 @@ func createRun(opts *CreateOptions) error { createLocalDirectory := opts.ConfirmSubmit if !opts.ConfirmSubmit { - opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID) + opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID, projectDirErr) if err != nil { return err } @@ -388,11 +388,13 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s return answers.RepoName, answers.RepoDescription, strings.ToUpper(answers.RepoVisibility), nil } -func confirmSubmission(repoName string, repoOwner string) (bool, error) { +func confirmSubmission(repoName string, repoOwner string, projectDirErr error) (bool, error) { qs := []*survey.Question{} promptString := "" - if repoOwner != "" { + if projectDirErr == nil { + promptString = fmt.Sprintf("This will add remote origin to your current directory. Continue? ") + } else if repoOwner != "" { promptString = fmt.Sprintf("This will create '%s/%s' in your current directory. Continue? ", repoOwner, repoName) } else { promptString = fmt.Sprintf("This will create '%s' in your current directory. Continue? ", repoName)