Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make git clone work in sites:create-template #4772

Merged
merged 3 commits into from
Jul 6, 2022

Conversation

danez
Copy link
Contributor

@danez danez commented Jul 4, 2022

Summary

git_url from the github api contains the plaintext git:// url which github itself does not support anymore. Instead, use the clone_url form the API which contains the https:// git URL

Currently when running the command this happens:

❯ ../netlify/cli/bin/run sites:create-template nextjs-blog-theme
? Team: Daniel Tschinder's team
Choose a unique site name (e.g. isnt-danez-awesome.netlify.app) or leave it blank for a random name. You can update the site name later.
? Site name (optional): undefined

Site Created

Admin URL: https://app.netlify.com/sites/isnt-danez-awesome
URL:       https://isnt-danez-awesome.netlify.app
Site ID:   429aa7d1-77fb-43ef-b45c-05857d885e46
Repo URL:  https://github.com/danez/isnt-danez-awesome
? Do you want to clone the repository? Yes

 ›   Error: Command failed with exit code 128: git clone git://github.com/danez/isnt-danez-awesome.git isnt-danez-awesome
Cloning into 'isnt-danez-awesome'...
fatal: unable to connect to github.com:
github.com[0: 140.82.121.4]: errno=Operation timed out


Additional

Also switch to use execa instead of git-clone to save one dependency. I checked what git-clone does internally and that is pretty much exactly what I do in this PR. git-clone has some advanced features, like custom path to git binary or checkout different branch after clone, but we are not using any of these.

No test was added, because we mock the whole github API, so even if I would mock execa and assert it was called with the mocked git URL, it won't test if the actual URL will work or not

`git_url` from the github api contains the plaintext git:// url which
github itself does not support anymore. Instead use the `clone_url`

Also switch to use `execa` instead of `git-clone` to save on dependency
@danez danez added the type: bug code to address defects in shipped code label Jul 4, 2022
@danez danez requested a review from a team July 4, 2022 16:06
@github-actions
Copy link

github-actions bot commented Jul 4, 2022

📊 Benchmark results

Comparing with 21a5d0c

Package size: 227 MB

⬇️ 0.02% decrease vs. 21a5d0c

^                                                                                                  227 MB 
│  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB  221 MB   ┌──┐  
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@danez danez requested a review from a team July 5, 2022 15:22
@danez
Copy link
Contributor Author

danez commented Jul 6, 2022

Maybe @netlify/templates could have a look because I guess this falls in your territory.

@tzmanics
Copy link
Contributor

tzmanics commented Jul 6, 2022

This worked great!!! Thanks for digging into this!! Much appreciated!

@danez danez added the automerge Add to Kodiak auto merge queue label Jul 6, 2022
Copy link
Contributor

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@kodiakhq kodiakhq bot merged commit 74527f4 into main Jul 6, 2022
@kodiakhq kodiakhq bot deleted the chore/danez-git-clone branch July 6, 2022 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants