From 4b64a4689177446e966d1cc6c35520d854af8d15 Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Tue, 4 Aug 2020 19:24:35 +0530 Subject: [PATCH 1/7] Add confirmation for risky step for repo create --- pkg/cmd/repo/create/create.go | 164 ++++++++++++++++++----------- pkg/cmd/repo/create/create_test.go | 31 ++++++ 2 files changed, 135 insertions(+), 60 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 313f9a91e..470e50467 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -6,6 +6,7 @@ import ( "path" "strings" + "github.com/AlecAivazis/survey/v2" "github.com/MakeNowJust/heredoc" "github.com/cli/cli/git" "github.com/cli/cli/internal/config" @@ -23,13 +24,14 @@ type CreateOptions struct { Config func() (config.Config, error) IO *iostreams.IOStreams - Name string - Description string - Homepage string - Team string - EnableIssues bool - EnableWiki bool - Public bool + Name string + Description string + Homepage string + Team string + EnableIssues bool + EnableWiki bool + Public bool + ConfirmSubmit bool } func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command { @@ -79,6 +81,7 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co cmd.Flags().BoolVar(&opts.EnableIssues, "enable-issues", true, "Enable issues in the new repository") cmd.Flags().BoolVar(&opts.EnableWiki, "enable-wiki", true, "Enable wiki in the new repository") cmd.Flags().BoolVar(&opts.Public, "public", false, "Make the new repository public (default: private)") + cmd.Flags().BoolVarP(&opts.ConfirmSubmit, "confirm", "y", false, "Confirm the submission directly") return cmd } @@ -126,68 +129,109 @@ func createRun(opts *CreateOptions) error { return err } - repo, err := repoCreate(httpClient, input) - if err != nil { - return err - } - - stderr := opts.IO.ErrOut - stdout := opts.IO.Out - greenCheck := utils.Green("✓") - isTTY := opts.IO.IsStdoutTTY() - - if isTTY { - fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n", greenCheck, ghrepo.FullName(repo)) - } else { - fmt.Fprintln(stdout, repo.URL) - } - - // TODO This is overly wordy and I'd like to streamline this. - cfg, err := opts.Config() - if err != nil { - return err - } - protocol, err := cfg.Get("", "git_protocol") - if err != nil { - return err - } - remoteURL := ghrepo.FormatRemoteURL(repo, protocol) - - if projectDirErr == nil { - _, err = git.AddRemote("origin", remoteURL) + if !opts.ConfirmSubmit { + opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID, &opts.ConfirmSubmit) if err != nil { return err } + } + + if opts.ConfirmSubmit { + repo, err := repoCreate(httpClient, input) + if err != nil { + return err + } + + stderr := opts.IO.ErrOut + stdout := opts.IO.Out + greenCheck := utils.Green("✓") + isTTY := opts.IO.IsStdoutTTY() + if isTTY { - fmt.Fprintf(stderr, "%s Added remote %s\n", greenCheck, remoteURL) + fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n", greenCheck, ghrepo.FullName(repo)) + } else { + fmt.Fprintln(stdout, repo.URL) } - } else if isTTY { - doSetup := false - err := prompt.Confirm(fmt.Sprintf("Create a local project directory for %s?", ghrepo.FullName(repo)), &doSetup) + + // TODO This is overly wordy and I'd like to streamline this. + cfg, err := opts.Config() if err != nil { return err } - - if doSetup { - path := repo.Name - - gitInit := git.GitCommand("init", path) - gitInit.Stdout = stdout - gitInit.Stderr = stderr - err = run.PrepareCmd(gitInit).Run() - if err != nil { - return err - } - gitRemoteAdd := git.GitCommand("-C", path, "remote", "add", "origin", remoteURL) - gitRemoteAdd.Stdout = stdout - gitRemoteAdd.Stderr = stderr - err = run.PrepareCmd(gitRemoteAdd).Run() - if err != nil { - return err - } - - fmt.Fprintf(stderr, "%s Initialized repository in './%s/'\n", greenCheck, path) + protocol, err := cfg.Get("", "git_protocol") + if err != nil { + return err } + remoteURL := ghrepo.FormatRemoteURL(repo, protocol) + + if projectDirErr == nil { + _, err = git.AddRemote("origin", remoteURL) + if err != nil { + return err + } + if isTTY { + fmt.Fprintf(stderr, "%s Added remote %s\n", greenCheck, remoteURL) + } + } else if isTTY { + doSetup := false + err := prompt.Confirm(fmt.Sprintf("Create a local project directory for %s?", ghrepo.FullName(repo)), &doSetup) + if err != nil { + return err + } + + if doSetup { + path := repo.Name + + gitInit := git.GitCommand("init", path) + gitInit.Stdout = stdout + gitInit.Stderr = stderr + err = run.PrepareCmd(gitInit).Run() + if err != nil { + return err + } + gitRemoteAdd := git.GitCommand("-C", path, "remote", "add", "origin", remoteURL) + gitRemoteAdd.Stdout = stdout + gitRemoteAdd.Stderr = stderr + err = run.PrepareCmd(gitRemoteAdd).Run() + if err != nil { + return err + } + + fmt.Fprintf(stderr, "%s Initialized repository in './%s/'\n", greenCheck, path) + } + } + return nil } + fmt.Fprintln(opts.IO.Out, "Discarding...") return nil } + +func confirmSubmission(repoName string, repoOwner string, isConfirmFlagPassed *bool) (bool, error) { + qs := []*survey.Question{} + + promptString := "" + 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) + } + + confirmSubmitQuestion := &survey.Question{ + Name: "confirmSubmit", + Prompt: &survey.Confirm{ + Message: promptString, + }, + } + qs = append(qs, confirmSubmitQuestion) + + answer := struct { + ConfirmSubmit bool + }{} + + err := prompt.SurveyAsk(qs, &answer) + if err != nil { + return false, err + } + + return answer.ConfirmSubmit, nil +} diff --git a/pkg/cmd/repo/create/create_test.go b/pkg/cmd/repo/create/create_test.go index d33ad5d25..dd7c5d2b5 100644 --- a/pkg/cmd/repo/create/create_test.go +++ b/pkg/cmd/repo/create/create_test.go @@ -14,6 +14,7 @@ import ( "github.com/cli/cli/pkg/cmdutil" "github.com/cli/cli/pkg/httpmock" "github.com/cli/cli/pkg/iostreams" + "github.com/cli/cli/pkg/prompt" "github.com/cli/cli/test" "github.com/google/shlex" "github.com/stretchr/testify/assert" @@ -87,6 +88,16 @@ func TestRepoCreate(t *testing.T) { }) defer restoreCmd() + as, surveyTearDown := prompt.InitAskStubber() + defer surveyTearDown() + + as.Stub([]*prompt.QuestionStub{ + { + Name: "confirmSubmit", + Value: true, + }, + }) + output, err := runCommand(httpClient, "REPO") if err != nil { t.Errorf("error running command `repo create`: %v", err) @@ -153,6 +164,16 @@ func TestRepoCreate_org(t *testing.T) { }) defer restoreCmd() + as, surveyTearDown := prompt.InitAskStubber() + defer surveyTearDown() + + as.Stub([]*prompt.QuestionStub{ + { + Name: "confirmSubmit", + Value: true, + }, + }) + output, err := runCommand(httpClient, "ORG/REPO") if err != nil { t.Errorf("error running command `repo create`: %v", err) @@ -219,6 +240,16 @@ func TestRepoCreate_orgWithTeam(t *testing.T) { }) defer restoreCmd() + as, surveyTearDown := prompt.InitAskStubber() + defer surveyTearDown() + + as.Stub([]*prompt.QuestionStub{ + { + Name: "confirmSubmit", + Value: true, + }, + }) + output, err := runCommand(httpClient, "ORG/REPO --team monkeys") if err != nil { t.Errorf("error running command `repo create`: %v", err) From 011f30977a3735b7137498e023a817b514cf3854 Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Thu, 6 Aug 2020 11:33:04 +0530 Subject: [PATCH 2/7] 1. Add three visibility tags - public, private, internal, one of which meeds to be passed. 2. Interactive repo create when no parameters are passed, i.e `repo create`. 3. Fix tests. TODO : write a repo in the form of user/repository format when no user is supplied. --- pkg/cmd/repo/create/create.go | 129 ++++++++++++++++++++++++++++- pkg/cmd/repo/create/create_test.go | 18 ++++ 2 files changed, 145 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 470e50467..c6d37285e 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -31,6 +31,8 @@ type CreateOptions struct { EnableIssues bool EnableWiki bool Public bool + Private bool + Internal bool ConfirmSubmit bool } @@ -80,7 +82,9 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co cmd.Flags().StringVarP(&opts.Team, "team", "t", "", "The name of the organization team to be granted access") cmd.Flags().BoolVar(&opts.EnableIssues, "enable-issues", true, "Enable issues in the new repository") cmd.Flags().BoolVar(&opts.EnableWiki, "enable-wiki", true, "Enable wiki in the new repository") - cmd.Flags().BoolVar(&opts.Public, "public", false, "Make the new repository public (default: private)") + cmd.Flags().BoolVar(&opts.Public, "public", false, "Make the new repository public") + cmd.Flags().BoolVar(&opts.Private, "private", false, "Make the new repository private") + cmd.Flags().BoolVar(&opts.Internal, "internal", false, "Make the new repository internal") cmd.Flags().BoolVarP(&opts.ConfirmSubmit, "confirm", "y", false, "Confirm the submission directly") return cmd @@ -92,7 +96,12 @@ func createRun(opts *CreateOptions) error { orgName := "" name := opts.Name + isNameAnArg := false + isDescEmpty := opts.Description == "" + isVisibilityPassed := false + if name != "" { + isNameAnArg = true if strings.Contains(name, "/") { newRepo, err := ghrepo.FromFullName(name) if err != nil { @@ -108,10 +117,52 @@ func createRun(opts *CreateOptions) error { name = path.Base(projectDir) } - visibility := "PRIVATE" + enabledFlagCount := 0 + visibility := "" if opts.Public { + enabledFlagCount++ visibility = "PUBLIC" } + if opts.Private { + enabledFlagCount++ + visibility = "PRIVATE" + } + if opts.Internal { + enabledFlagCount++ + visibility = "INTERNAL" + } + + if enabledFlagCount > 1 { + return fmt.Errorf("expected exactly one of --public, --private, or --internal to be true") + } else if enabledFlagCount == 1 { + isVisibilityPassed = true + } + + // Trigger interactive prompt if name is not passed + if !isNameAnArg { + newName, newDesc, newVisibility, err := interactiveRepoCreate(isDescEmpty, isVisibilityPassed, name) + if err != nil { + return err + } + if newName != "" { + name = newName + } + if newDesc != "" { + opts.Description = newDesc + } + if newVisibility != "" { + visibility = newVisibility + } + } else { + // Go for a prompt only if visibility isn't passed + if !isVisibilityPassed { + newVisibility, err := getVisibility() + if err != nil { + return nil + } + visibility = newVisibility + } + } input := repoCreateInput{ Name: name, @@ -206,6 +257,56 @@ func createRun(opts *CreateOptions) error { return nil } +func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName string) (string, string, string, error) { + qs := []*survey.Question{} + + repoOwnerQuestion := &survey.Question{ + Name: "repoOwner", + Prompt: &survey.Input{ + Message: "Repository name", + Default: repoName, + }, + } + qs = append(qs, repoOwnerQuestion) + + if isDescEmpty { + repoDescriptionQuestion := &survey.Question{ + Name: "repoDescription", + Prompt: &survey.Input{ + Message: "Repository description", + }, + } + + qs = append(qs, repoDescriptionQuestion) + } + + if !isVisibilityPassed { + repoVisibilityQuestion := &survey.Question{ + Name: "repoVisibility", + Prompt: &survey.Select{ + Message: "Visibility", + Options: []string{"PUBLIC", "PRIVATE", "INTERNAL"}, + }, + } + qs = append(qs, repoVisibilityQuestion) + } + + answers := struct { + RepoOwner string + RepoDescription string + RepoVisibility string + }{} + + err := prompt.SurveyAsk(qs, &answers) + + if err != nil { + return "", "", "", err + } + + return answers.RepoOwner, answers.RepoDescription, answers.RepoVisibility, nil + +} + func confirmSubmission(repoName string, repoOwner string, isConfirmFlagPassed *bool) (bool, error) { qs := []*survey.Question{} @@ -235,3 +336,27 @@ func confirmSubmission(repoName string, repoOwner string, isConfirmFlagPassed *b return answer.ConfirmSubmit, nil } + +func getVisibility() (string, error) { + qs := []*survey.Question{} + + getVisibilityQuestion := &survey.Question{ + Name: "repoVisibility", + Prompt: &survey.Select{ + Message: "Visibility", + Options: []string{"PUBLIC", "PRIVATE", "INTERNAL"}, + }, + } + qs = append(qs, getVisibilityQuestion) + + answer := struct { + RepoVisibility string + }{} + + err := prompt.SurveyAsk(qs, &answer) + if err != nil { + return "", err + } + + return answer.RepoVisibility, nil +} diff --git a/pkg/cmd/repo/create/create_test.go b/pkg/cmd/repo/create/create_test.go index dd7c5d2b5..25f5519ab 100644 --- a/pkg/cmd/repo/create/create_test.go +++ b/pkg/cmd/repo/create/create_test.go @@ -91,6 +91,12 @@ func TestRepoCreate(t *testing.T) { as, surveyTearDown := prompt.InitAskStubber() defer surveyTearDown() + as.Stub([]*prompt.QuestionStub{ + { + Name: "repoVisibility", + Value: "PRIVATE", + }, + }) as.Stub([]*prompt.QuestionStub{ { Name: "confirmSubmit", @@ -167,6 +173,12 @@ func TestRepoCreate_org(t *testing.T) { as, surveyTearDown := prompt.InitAskStubber() defer surveyTearDown() + as.Stub([]*prompt.QuestionStub{ + { + Name: "repoVisibility", + Value: "PRIVATE", + }, + }) as.Stub([]*prompt.QuestionStub{ { Name: "confirmSubmit", @@ -243,6 +255,12 @@ func TestRepoCreate_orgWithTeam(t *testing.T) { as, surveyTearDown := prompt.InitAskStubber() defer surveyTearDown() + as.Stub([]*prompt.QuestionStub{ + { + Name: "repoVisibility", + Value: "PRIVATE", + }, + }) as.Stub([]*prompt.QuestionStub{ { Name: "confirmSubmit", From d3a44f827f548b51c4255aab13de0157257ad80d Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Thu, 6 Aug 2020 11:47:24 +0530 Subject: [PATCH 3/7] Permit -y flag to create local directory as well --- pkg/cmd/repo/create/create.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index c6d37285e..c737599b1 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -224,12 +224,13 @@ func createRun(opts *CreateOptions) error { fmt.Fprintf(stderr, "%s Added remote %s\n", greenCheck, remoteURL) } } else if isTTY { - doSetup := false - err := prompt.Confirm(fmt.Sprintf("Create a local project directory for %s?", ghrepo.FullName(repo)), &doSetup) - if err != nil { - return err + doSetup := opts.ConfirmSubmit + if !doSetup { + err := prompt.Confirm(fmt.Sprintf("Create a local project directory for %s?", ghrepo.FullName(repo)), &doSetup) + if err != nil { + return err + } } - if doSetup { path := repo.Name From 43ace4dc54afbf543168831fd88d5b802c7c22d5 Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Thu, 6 Aug 2020 12:20:39 +0530 Subject: [PATCH 4/7] Fix tests failing after merging trunk --- pkg/cmd/repo/create/create.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 42d4d88d8..3bf309c50 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -198,12 +198,17 @@ func createRun(opts *CreateOptions) error { greenCheck := utils.Green("✓") isTTY := opts.IO.IsStdoutTTY() + if isTTY { + fmt.Fprintf(stderr, "%s Created repository %s on GitHub\n", greenCheck, ghrepo.FullName(repo)) + } else { + fmt.Fprintln(stdout, repo.URL) + } + // TODO This is overly wordy and I'd like to streamline this. cfg, err := opts.Config() if err != nil { return err } - // TODO: GHE support protocol, err := cfg.Get("", "git_protocol") if err != nil { return err @@ -252,7 +257,6 @@ func createRun(opts *CreateOptions) error { fmt.Fprintln(opts.IO.Out, "Discarding...") return nil } - func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName string) (string, string, string, error) { qs := []*survey.Question{} From 130c5262b29f88ad3346ba7c736a596c1d2816b0 Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Tue, 18 Aug 2020 16:23:16 +0530 Subject: [PATCH 5/7] Refactor changes --- pkg/cmd/repo/create/create.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 6dded0159..5abd9a96f 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -99,10 +99,11 @@ func createRun(opts *CreateOptions) error { isDescEmpty := opts.Description == "" isVisibilityPassed := false - if name != "" { + if opts.Name != "" { isNameAnArg = true - if strings.Contains(name, "/") { - newRepo, err := ghrepo.FromFullName(name) + if strings.Contains(opts.Name, "/") { + var err error + repoToCreate, err = ghrepo.FromFullName(opts.Name) if err != nil { return fmt.Errorf("argument error: %w", err) } @@ -139,12 +140,12 @@ func createRun(opts *CreateOptions) error { // Trigger interactive prompt if name is not passed if !isNameAnArg { - newName, newDesc, newVisibility, err := interactiveRepoCreate(isDescEmpty, isVisibilityPassed, name) + newName, newDesc, newVisibility, err := interactiveRepoCreate(isDescEmpty, isVisibilityPassed, repoToCreate.RepoName()) if err != nil { return err } if newName != "" { - name = newName + opts.Name = newName } if newDesc != "" { opts.Description = newDesc @@ -187,7 +188,7 @@ func createRun(opts *CreateOptions) error { } if opts.ConfirmSubmit { - repo, err := repoCreate(httpClient, input) + repo, err := repoCreate(httpClient, repoToCreate.RepoHost(), input) if err != nil { return err } @@ -208,7 +209,7 @@ func createRun(opts *CreateOptions) error { if err != nil { return err } - protocol, err := cfg.Get("", "git_protocol") + protocol, err := cfg.Get(repo.RepoHost(), "git_protocol") if err != nil { return err } @@ -248,7 +249,7 @@ func createRun(opts *CreateOptions) error { return err } - fmt.Fprintf(stderr, "%s Initialized repository in './%s/'\n", greenCheck, path) + fmt.Fprintf(stderr, "%s Initialized repository in './%s/'\n", utils.GreenCheck(), path) } } return nil @@ -256,6 +257,7 @@ func createRun(opts *CreateOptions) error { fmt.Fprintln(opts.IO.Out, "Discarding...") return nil } + func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName string) (string, string, string, error) { qs := []*survey.Question{} @@ -284,7 +286,7 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s Name: "repoVisibility", Prompt: &survey.Select{ Message: "Visibility", - Options: []string{"PUBLIC", "PRIVATE", "INTERNAL"}, + Options: []string{"Public", "Private", "Internal"}, }, } qs = append(qs, repoVisibilityQuestion) @@ -302,7 +304,7 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s return "", "", "", err } - return answers.RepoOwner, answers.RepoDescription, answers.RepoVisibility, nil + return answers.RepoOwner, answers.RepoDescription, strings.ToUpper(answers.RepoVisibility), nil } @@ -311,15 +313,16 @@ func confirmSubmission(repoName string, repoOwner string, isConfirmFlagPassed *b promptString := "" if repoOwner != "" { - promptString = fmt.Sprintf("This will create %s/%s in your current directory. Continue? ", repoOwner, repoName) + 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) + promptString = fmt.Sprintf("This will create '%s' in your current directory. Continue? ", repoName) } confirmSubmitQuestion := &survey.Question{ Name: "confirmSubmit", Prompt: &survey.Confirm{ Message: promptString, + Default: true, }, } qs = append(qs, confirmSubmitQuestion) From 00b2777a147a7d94d82bebd80b9878e21591e756 Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Thu, 20 Aug 2020 14:10:18 +0530 Subject: [PATCH 6/7] Change visibility strings to Sentence case --- pkg/cmd/repo/create/create.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 5abd9a96f..08f16c0bd 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -346,7 +346,7 @@ func getVisibility() (string, error) { Name: "repoVisibility", Prompt: &survey.Select{ Message: "Visibility", - Options: []string{"PUBLIC", "PRIVATE", "INTERNAL"}, + Options: []string{"Public", "Private", "Internal"}, }, } qs = append(qs, getVisibilityQuestion) @@ -360,5 +360,5 @@ func getVisibility() (string, error) { return "", err } - return answer.RepoVisibility, nil + return strings.ToUpper(answer.RepoVisibility), nil } From 7955c4f2ed60d47a9c7c61fbe9ffc8601631ab8e Mon Sep 17 00:00:00 2001 From: ShubhankarKG Date: Thu, 20 Aug 2020 14:20:55 +0530 Subject: [PATCH 7/7] doSetup wasn't getting called in cases where required. The problem was that opts.confirmSubmit was mutated before reaching doSetup. This commit creates a copy of the initial confirmSubmit value. So the doSetup receives the initial data passed from the command, not the mutated one. --- pkg/cmd/repo/create/create.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index 08f16c0bd..7628184e5 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -180,6 +180,7 @@ func createRun(opts *CreateOptions) error { return err } + createLocalDirectory := opts.ConfirmSubmit if !opts.ConfirmSubmit { opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID, &opts.ConfirmSubmit) if err != nil { @@ -224,7 +225,7 @@ func createRun(opts *CreateOptions) error { fmt.Fprintf(stderr, "%s Added remote %s\n", greenCheck, remoteURL) } } else if isTTY { - doSetup := opts.ConfirmSubmit + doSetup := createLocalDirectory if !doSetup { err := prompt.Confirm(fmt.Sprintf("Create a local project directory for %s?", ghrepo.FullName(repo)), &doSetup) if err != nil {