π (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:
parent
8016244dbb
commit
a5400effd8
2 changed files with 30 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
Loadingβ¦
Add table
Add a link
Reference in a new issue