From e461baa217f7ea3f723460e8ff4b8ab17443841b Mon Sep 17 00:00:00 2001 From: ulwlu Date: Sat, 13 Feb 2021 17:11:08 +0900 Subject: [PATCH 1/3] 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) From 16be90c53828aeb36916a068ac10ced53a4f5ef8 Mon Sep 17 00:00:00 2001 From: ulwlu Date: Sat, 13 Feb 2021 17:20:39 +0900 Subject: [PATCH 2/3] Fix unnecessary Sprintf with Sprint --- pkg/cmd/repo/create/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 11007f40c..42285012d 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -393,7 +393,7 @@ func confirmSubmission(repoName string, repoOwner string, projectDirErr error) ( promptString := "" if projectDirErr == nil { - promptString = fmt.Sprintf("This will add remote origin to your current directory. Continue? ") + promptString = fmt.Sprint("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 { From 95a8f926abc2e5afc7886400ccd4d92fde83d574 Mon Sep 17 00:00:00 2001 From: ulwlu Date: Sat, 13 Feb 2021 18:10:38 +0900 Subject: [PATCH 3/3] Remove unnecessary Sprint --- pkg/cmd/repo/create/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 42285012d..2aa7834ea 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -393,7 +393,7 @@ func confirmSubmission(repoName string, repoOwner string, projectDirErr error) ( promptString := "" if projectDirErr == nil { - promptString = fmt.Sprint("This will add remote origin to your current directory. Continue? ") + promptString = "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 {