Skip to content

Commit

Permalink
πŸ› (repo create)execute clone when readme option is enabled (cli#7837)
Browse files Browse the repository at this point in the history
* πŸ› (repo create)execute clone when readme option is enabled

* βœ… (repo/create)noninteractive clone with readme

* πŸ”₯ (repo/create)remove printing statement
  • Loading branch information
Shion1305 authored Aug 28, 2023
1 parent 8016244 commit a5400ef
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cmd/repo/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func createFromScratch(opts *CreateOptions) error {

remoteURL := ghrepo.FormatRemoteURL(repo, protocol)

if opts.LicenseTemplate == "" && opts.GitIgnoreTemplate == "" && opts.Template == "" {
if !opts.AddReadme && opts.LicenseTemplate == "" && opts.GitIgnoreTemplate == "" && opts.Template == "" {
// cloning empty repository or template
if err := localInit(opts.GitClient, remoteURL, repo.RepoName()); err != nil {
return err
Expand Down
29 changes: 29 additions & 0 deletions pkg/cmd/repo/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,35 @@ func Test_createRun(t *testing.T) {
},
wantStdout: "https://github.com/OWNER/REPO\n",
},
{
name: "noninteractive clone with readme",
opts: &CreateOptions{
Interactive: false,
Name: "ElliotAlderson",
Visibility: "PRIVATE",
Clone: true,
AddReadme: true,
},
tty: false,
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("POST", "user/repos"),
httpmock.RESTPayload(200, "{\"name\":\"ElliotAlderson\", \"owner\":{\"login\": \"OWNER\"}, \"html_url\":\"https://github.com/OWNER/ElliotAlderson\"}",
func(payload map[string]interface{}) {
payload["name"] = "ElliotAlderson"
payload["owner"] = map[string]interface{}{"login": "OWNER"}
payload["auto_init"] = true
payload["private"] = true
},
),
)
},
execStubs: func(cs *run.CommandStubber) {
cs.Register(`git clone https://github.com/OWNER/ElliotAlderson`, 128, "")
cs.Register(`git clone https://github.com/OWNER/ElliotAlderson`, 0, "")
},
wantStdout: "https://github.com/OWNER/ElliotAlderson\n",
},
{
name: "noninteractive create from template with retry",
opts: &CreateOptions{
Expand Down

0 comments on commit a5400ef

Please sign in to comment.