πŸ› (repo create)execute clone when readme option is enabled (#7837)

* πŸ› (repo create)execute clone when readme option is enabled

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

* πŸ”₯ (repo/create)remove printing statement
This commit is contained in:
Shion Ichikawa 2023-08-28 23:09:02 +09:00 β€’ committed by GitHub
parent 8016244dbb
commit a5400effd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View file

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

View file

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