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.
This commit is contained in:
ulwlu 2021-02-13 17:11:08 +09:00
parent 4e5aa91fac
commit e461baa217
No known key found for this signature in database
GPG key ID: 5D970017CA0286BA

View file

@ -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)