From 7639c2608a11315b7099931757a3885c2306a3bf Mon Sep 17 00:00:00 2001 From: Nick Mitchinson Date: Tue, 28 Aug 2018 01:45:39 -0500 Subject: [PATCH] Prevent setting a public upstream when creating a private repo. Fixes #1854 --- commands/create.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/commands/create.go b/commands/create.go index f75e474d..47f31652 100644 --- a/commands/create.go +++ b/commands/create.go @@ -110,7 +110,18 @@ func create(command *Command, args *Args) { gh := github.NewClient(project.Host) if gh.IsRepositoryExist(project) { - ui.Errorln("Existing repository detected. Updating git remote") + + repo, err := gh.Repository(project) + if err != nil { + utils.Check(err) + } + + if !repo.Private && flagCreatePrivate { + err = fmt.Errorf("Existing public repository detected. git remote not updated") + utils.Check(err) + } else { + ui.Errorln("Existing repository detected. Updating git remote") + } } else { if !args.Noop { repo, err := gh.CreateRepository(project, flagCreateDescription, flagCreateHomepage, flagCreatePrivate)