Skip to content

Commit 4a56280

Browse files
committed
Automatically add origin remote after repo create
1 parent b02dac8 commit 4a56280

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

command/repo.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ func repoCreate(cmd *cobra.Command, args []string) error {
137137
return err
138138
}
139139

140+
remoteAdd := git.GitCommand("remote", "add", "origin", repo.URL+".git")
141+
remoteAdd.Stdout = os.Stdout
142+
remoteAdd.Stderr = os.Stderr
143+
err = utils.PrepareCmd(remoteAdd).Run()
144+
if err != nil {
145+
return err
146+
}
147+
140148
fmt.Fprintln(cmd.OutOrStdout(), repo.URL)
141149
return nil
142150
}

command/repo_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ func TestRepoCreate(t *testing.T) {
9696
eq(t, output.String(), "https://github.com/OWNER/REPO\n")
9797
eq(t, output.Stderr(), "")
9898

99-
if seenCmd != nil {
99+
if seenCmd == nil {
100100
t.Fatal("expected a command to run")
101101
}
102+
eq(t, strings.Join(seenCmd.Args, " "), "git remote add origin https://github.com/OWNER/REPO.git")
102103

103104
var reqBody struct {
104105
Query string

0 commit comments

Comments
 (0)