wrangler-legacy icon indicating copy to clipboard operation
wrangler-legacy copied to clipboard

Wrangler generate accept a branch option for the template repository

Open p-j opened this issue 4 years ago • 7 comments
trafficstars

What this PR does:

  • introduce a branch param to the generate command to select a branch on the template used
  • branch param defaults to master
  • branch param is passed down to cargo_generate

Context:

  • Github default branch has switched from master to main
  • I've recently created a template here p-j/worker-eapi-template I can't install with the current version of wrangler generate since the default branch is main and not master: I'm getting the following error from cargo_generate : Git Error: failed to find branch master
  • cargo_generate can take in a branch param, which is what this PR use.

Outcome:

Once build & installed, I can successfully run

  • wrangler generate test-worker
  • wrangler generate my-ts-project https://github.com/p-j/worker-eapi-template --branch=main
  • wrangler generate my-ts-project p-j/worker-eapi-template --branch=main thanks to the upgrade of cargo_generate to 0.5.1

It's my first time ever writing some rust so do let me know if I'm not doing things correctly 👨‍🎓

p-j avatar Nov 19 '20 10:11 p-j

The tests on windows seems unstable, they were passing before I fixed the update on the README and force pushed it.

p-j avatar Nov 26 '20 10:11 p-j

I'm running the test suite locally on WSL and everything checks out, I'm unsure why it's not running correctly on the CI.

p-j avatar Dec 01 '20 09:12 p-j

Thanks for working on this! I'm unsure if defaulting the branch to master is the right approach, especially as you pointed out, Github and other projects are using different default branches. If wrangler generate provides no --branch parameter, can we just default to the project's default branch?

Electroid avatar Mar 12 '21 16:03 Electroid

I'd be more than fine with that as well. Since cargo-generate v0.5.2 it is indeed possible to use the default branch directly instead of defaulting to master. So it would make sense to take advantage of that and while keeping the --branch parameter to be more flexible and remove the master default.

p-j avatar Mar 13 '21 23:03 p-j

I've updated the PR to make use of the 0.6.0 of cargo-generate and remove the master default. Unfortunately, as pointed out by @xortive their latest versions have no binary release. I've made this change a single commit so it's easy to revert.

p-j avatar Mar 14 '21 00:03 p-j

This issue has been automatically marked as stale because it has not had recent activity in the last 180 days. It will be closed if no further activity occurs in the next week. Please feel free to comment if you'd like it to remain open, and thank you for your contributions.

stale[bot] avatar Sep 19 '21 20:09 stale[bot]

I'll see to rebase this and update to latest version of cargo-generate which does provide binaries again

p-j avatar Sep 24 '21 07:09 p-j

Thanks for creating this PR! Wrangler v1 is now deprecated and support is only being provided for critical updates or security concerns. As such, we are closing this PR.

New versions of Wrangler are maintained in the workers-sdk repo. If you are running into a similar issue with wrangler v2, please report it or create a new PR in the workers-sdk repo. For more info about wrangler v1 deprecation, please check out our blog post.

JacobMGEvans avatar Feb 27 '23 16:02 JacobMGEvans