Automatically add origin remote after repo create

This commit is contained in:
Mislav Marohnić 2020-02-26 19:53:01 +01:00
parent b02dac8f0b
commit 4a56280ab5
2 changed files with 10 additions and 1 deletions

View file

@ -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
}

View file

@ -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