Skip to content

Commit a8fdd9a

Browse files
committed
Further clarify what will happen on repo create
In local git directory: 1. `This will add an "origin" git remote to your local repository. Continue?` 2. "origin" git remote is added in current directory. Outside of a local git directory: 1. This will create the "REPO" repository on GitHub. Continue? 2. `Create a local project directory for "REPO"?` 3. new directory called "REPO" now set up for the GitHub repository.
1 parent e91b97b commit a8fdd9a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pkg/cmd/repo/create/create.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func createRun(opts *CreateOptions) error {
132132
isNameAnArg := false
133133
isDescEmpty := opts.Description == ""
134134
isVisibilityPassed := false
135+
inLocalRepo := projectDirErr == nil
135136

136137
if opts.Name != "" {
137138
isNameAnArg = true
@@ -250,7 +251,7 @@ func createRun(opts *CreateOptions) error {
250251

251252
createLocalDirectory := opts.ConfirmSubmit
252253
if !opts.ConfirmSubmit {
253-
opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID, projectDirErr)
254+
opts.ConfirmSubmit, err = confirmSubmission(input.Name, input.OwnerID, inLocalRepo)
254255
if err != nil {
255256
return err
256257
}
@@ -284,7 +285,7 @@ func createRun(opts *CreateOptions) error {
284285
}
285286
remoteURL := ghrepo.FormatRemoteURL(repo, protocol)
286287

287-
if projectDirErr == nil {
288+
if inLocalRepo {
288289
_, err = git.AddRemote("origin", remoteURL)
289290
if err != nil {
290291
return err
@@ -295,7 +296,7 @@ func createRun(opts *CreateOptions) error {
295296
} else {
296297
if opts.IO.CanPrompt() {
297298
if !createLocalDirectory {
298-
err := prompt.Confirm(fmt.Sprintf("Create a local project directory for %s?", ghrepo.FullName(repo)), &createLocalDirectory)
299+
err := prompt.Confirm(fmt.Sprintf(`Create a local project directory for "%s"?`, ghrepo.FullName(repo)), &createLocalDirectory)
299300
if err != nil {
300301
return err
301302
}
@@ -388,16 +389,18 @@ func interactiveRepoCreate(isDescEmpty bool, isVisibilityPassed bool, repoName s
388389
return answers.RepoName, answers.RepoDescription, strings.ToUpper(answers.RepoVisibility), nil
389390
}
390391

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

394395
promptString := ""
395-
if projectDirErr == nil {
396-
promptString = "This will add remote origin to your current directory. Continue? "
397-
} else if repoOwner != "" {
398-
promptString = fmt.Sprintf("This will create '%s/%s' in your current directory. Continue? ", repoOwner, repoName)
396+
if inLocalRepo {
397+
promptString = `This will add an "origin" git remote to your local repository. Continue?`
399398
} else {
400-
promptString = fmt.Sprintf("This will create '%s' in your current directory. Continue? ", repoName)
399+
targetRepo := repoName
400+
if repoOwner != "" {
401+
targetRepo = fmt.Sprintf("%s/%s", repoOwner, repoName)
402+
}
403+
promptString = fmt.Sprintf(`This will create the "%s" repository on GitHub. Continue?`, targetRepo)
401404
}
402405

403406
confirmSubmitQuestion := &survey.Question{

0 commit comments

Comments
 (0)