From e2be7f1960b6863029283e0ac4a9b0ceb714100b Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Sat, 9 Feb 2019 13:11:53 +0100 Subject: [PATCH] remote name can be specified in the create command --- commands/create.go | 8 +++++++- features/create.feature | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/commands/create.go b/commands/create.go index 13462497..067ce438 100644 --- a/commands/create.go +++ b/commands/create.go @@ -128,7 +128,13 @@ func create(command *Command, args *Args) { localRepo, err := github.LocalRepo() utils.Check(err) - originName := "origin" + var originName string + if flagOriginRemoteName := args.Flag.Value("--remote-name"); flagOriginRemoteName != "" { + originName = flagOriginRemoteName + } else { + originName = "origin" + } + if originRemote, err := localRepo.RemoteByName(originName); err == nil { originProject, err := originRemote.Project() if err != nil || !originProject.SameAs(project) { diff --git a/features/create.feature b/features/create.feature index 83475d0a..1b438c8e 100644 --- a/features/create.feature +++ b/features/create.feature @@ -27,6 +27,17 @@ Feature: hub create """ When I successfully run `hub create -p` Then the url for "origin" should be "git@github.com:mislav/dotfiles.git" + Scenario: Create repo with new remote name specified + Given the GitHub API server: + """ + post('/user/repos') { + assert :private => false + status 201 + json :full_name => 'mislav/dotfiles' + } + """ + When I sucessfully run `hub create --remote-name=work` + Then the url for "work" should be "git@github.com:mislav/dotfiles.git" Scenario: HTTPS is preferred Given the GitHub API server: