diff --git a/command/repo.go b/command/repo.go index 905885c00..40e3847fb 100644 --- a/command/repo.go +++ b/command/repo.go @@ -137,6 +137,14 @@ func repoCreate(cmd *cobra.Command, args []string) error { return err } + remoteAdd := git.GitCommand("remote", "add", "origin", repo.URL+".git") + remoteAdd.Stdout = os.Stdout + remoteAdd.Stderr = os.Stderr + err = utils.PrepareCmd(remoteAdd).Run() + if err != nil { + return err + } + fmt.Fprintln(cmd.OutOrStdout(), repo.URL) return nil } diff --git a/command/repo_test.go b/command/repo_test.go index 04bda3f6a..e6cea29a8 100644 --- a/command/repo_test.go +++ b/command/repo_test.go @@ -96,9 +96,10 @@ func TestRepoCreate(t *testing.T) { eq(t, output.String(), "https://github.com/OWNER/REPO\n") eq(t, output.Stderr(), "") - if seenCmd != nil { + if seenCmd == nil { t.Fatal("expected a command to run") } + eq(t, strings.Join(seenCmd.Args, " "), "git remote add origin https://github.com/OWNER/REPO.git") var reqBody struct { Query string