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

Query crate versions from local registry index rather than HTTP API #317

Merged
merged 25 commits into from
Aug 7, 2019
Merged

Query crate versions from local registry index rather than HTTP API #317

merged 25 commits into from
Aug 7, 2019

Conversation

DCjanus
Copy link
Contributor

@DCjanus DCjanus commented Jun 27, 2019

Close #311

src/registry.rs Outdated Show resolved Hide resolved
src/fetch.rs Outdated Show resolved Hide resolved
@DCjanus DCjanus changed the title [WIP] Query crate versions from local registry index rather than HTTP API Query crate versions from local registry index rather than HTTP API Jul 16, 2019
@DCjanus
Copy link
Contributor Author

DCjanus commented Jul 16, 2019

@ordian Hi, since your last comment, I did a lot of changes, would you mind review again?

recommend: review one commit by one commit.

Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

This is great work, @DCjanus, thank you!
Looks good overalls, but the thing that worries me here is a lack of tests. Do you think it would be possible to add some?

src/fetch.rs Outdated Show resolved Hide resolved
src/errors.rs Outdated Show resolved Hide resolved
src/errors.rs Outdated Show resolved Hide resolved
src/errors.rs Outdated Show resolved Hide resolved
src/fetch.rs Outdated Show resolved Hide resolved
src/fetch.rs Outdated Show resolved Hide resolved
src/registry.rs Show resolved Hide resolved
src/fetch.rs Outdated Show resolved Hide resolved
src/registry.rs Outdated Show resolved Hide resolved
src/fetch.rs Show resolved Hide resolved
src/registry.rs Outdated Show resolved Hide resolved
src/fetch.rs Outdated Show resolved Hide resolved
src/errors.rs Outdated Show resolved Hide resolved
@DCjanus
Copy link
Contributor Author

DCjanus commented Jul 20, 2019

force push: resolve conflict

@ordian
Copy link
Collaborator

ordian commented Jul 21, 2019

It seems like appveyor CI is failing because libgit2 doesn't work on pc-windows-gnu targets.

The code looks ok, but I'd like get more reviews on this. @killercup @bjgill

@bjgill
Copy link
Collaborator

bjgill commented Jul 24, 2019

(I'll put this on my list of things to review; will try and take a look this week)

@bjgill bjgill self-requested a review July 24, 2019 16:36
Copy link
Collaborator

@bjgill bjgill left a comment

Choose a reason for hiding this comment

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

Done a brief first pass. I really like the idea of speeding cargo-edit up and stopping using the HTTP API. Do you know how big the speed-up is?

A few smaller comments below.

As Appveyor identified, this change means that cargo-edit will no longer work with pc-windows-gnu. Is this acceptable/is the number of users small? I'm a bit nervous about dropping support for a tier 1 toolchain.

src/errors.rs Outdated Show resolved Hide resolved
src/fetch.rs Show resolved Hide resolved
src/fetch.rs Show resolved Hide resolved
@DCjanus
Copy link
Contributor Author

DCjanus commented Jul 25, 2019

I believe the problem on Windows-gnu could be resolved, I'm going to try this in this week.

@DCjanus DCjanus changed the title Query crate versions from local registry index rather than HTTP API WIP: Query crate versions from local registry index rather than HTTP API Jul 25, 2019
@DCjanus
Copy link
Contributor Author

DCjanus commented Jul 26, 2019

My friend has told me how to fix this problem: rust-lang/rust#53454

And maybe, we could query registry index via git-cli rather than libgit2, with this, I believe that cost less compile time. But this requires the user to have to install git, I am not sure if this is acceptable.

For example:

$ git rev-parse refs/remotes/origin/master
e000bd939a83dfbb64da285425186af30178042b

$ git ls-tree e000bd939a83dfbb64da285425186af30178042b
040000 tree 2e03f39bea7b299346dd61f76223b0622a5c3ca5    1
040000 tree 766307154d671917d2ae02ca00035e7d7a96b711    2
040000 tree 62382fdc0c2d60f11eb1ffb4c9382bd360415625    3
040000 tree ea15ada1fa58ff60180e5768fc096279038d0fab    a-
040000 tree 669a2b1afa7d00b43c2e0eb72af40f85d6608993    aa
040000 tree d10ac8d5d8de21947dcd5a8bf7b19203480a80c1    ab
.... # some output

$ git cat-file -p 999e8ba108a3d80be1c24a4323e05fce422e2533 # a blob object hash that I found in my registry index
{"name":"dargo","vers":"0.0.0","deps":[],"cksum":"25ccfb6ab26454d5bd4c6a1391bb97a920ad0bfef13a25d5125e3e2ba8a6ebb1","features":{},"yanked":false,"links":null}
{"name":"dargo","vers":"0.0.1","deps":[{"name":"cargo","req":"^0.35.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"colored","req":"^1.8.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"failure","req":"^0.1.5","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"flexi_logger","req":"^0.13.1","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"log","req":"^0.4.6","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"semver","req":"^0.9.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"structopt","req":"^0.2.16","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"tabwriter","req":"^1.1.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"toml_edit","req":"^0.1.3","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"}],"cksum":"babf4f39a8d8e51ce26cca6f3481401a7db37b3c8944f07407b69aaab9d0ce2e","features":{},"yanked":false,"links":null}
{"name":"dargo","vers":"0.0.2","deps":[{"name":"cargo","req":"^0.35.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"colored","req":"^1.8.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"failure","req":"^0.1.5","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"flexi_logger","req":"^0.13.1","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"log","req":"^0.4.6","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"semver","req":"^0.9.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"structopt","req":"^0.2.16","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"tabwriter","req":"^1.1.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"toml_edit","req":"^0.1.3","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"}],"cksum":"c499b31da448619f627099e8f9951d49d80639f5e622d73832f86ad899454953","features":{},"yanked":false,"links":null}
{"name":"dargo","vers":"0.0.3","deps":[{"name":"cargo","req":"^0.35.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"colored","req":"^1.8.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"failure","req":"^0.1.5","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"flexi_logger","req":"^0.13.1","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"log","req":"^0.4.6","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"semver","req":"^0.9.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"structopt","req":"^0.2.16","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"tabwriter","req":"^1.1.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"toml_edit","req":"^0.1.3","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"}],"cksum":"769f10a0e29b4a97e81555d06b2dae04e80d0cf76911c37609a938f35259f8be","features":{},"yanked":false,"links":null}
{"name":"dargo","vers":"0.0.4","deps":[{"name":"cargo","req":"^0.36.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"colored","req":"^1.8.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"failure","req":"^0.1.5","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"flexi_logger","req":"^0.13.2","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"log","req":"^0.4.6","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"semver","req":"^0.9.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"structopt","req":"^0.2.17","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"tabwriter","req":"^1.1.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"toml_edit","req":"^0.1.3","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"}],"cksum":"a4f5474ec1099fc7a8f57632027c8f3f42edbba9f5bfd83fa7894361d5aaa991","features":{},"yanked":false,"links":null}
{"name":"dargo","vers":"0.0.5","deps":[{"name":"cargo","req":"^0.36.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"colored","req":"^1.8.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"failure","req":"^0.1.5","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"flexi_logger","req":"^0.13.2","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"log","req":"^0.4.6","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"semver","req":"^0.9.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"structopt","req":"^0.2.16","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"tabwriter","req":"^1.1.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"toml_edit","req":"^0.1.3","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"}],"cksum":"670e5c55a81f5693c33360d8fb84b4f1a0f166aceea977cb571142e2f0f283b2","features":{},"yanked":true,"links":null}
{"name":"dargo","vers":"0.0.6","deps":[{"name":"cargo","req":"^0.36.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"colored","req":"^1.8.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"failure","req":"^0.1.5","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"flexi_logger","req":"^0.13.2","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"log","req":"^0.4.6","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"semver","req":"^0.9.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"structopt","req":"^0.2.16","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"tabwriter","req":"^1.1.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"},{"name":"toml_edit","req":"^0.1.3","features":[],"optional":false,"default_features":true,"target":null,"kind":"normal"}],"cksum":"12675eb23f091fcc331d58bb0a6dc84702a2529fd333456db5d86d33e8aaafda","features":{},"yanked":false,"links":null}

@ordian
Copy link
Collaborator

ordian commented Jul 26, 2019

As Appveyor identified, this change means that cargo-edit will no longer work with pc-windows-gnu. Is this acceptable/is the number of users small? I'm a bit nervous about dropping support for a tier 1 toolchain.

This is a valid concern, but I think the number of pc-windows-gnu target's users is pretty small (they could probably use pc-windows-msvc as well) and would be in favor of dropping support for it for now and let the issue be fixed upstream (in rust/libgit2) rather than require a user to have git installed and run it in CLI mode.
Let me know if you don't agree.

@DCjanus
Copy link
Contributor Author

DCjanus commented Jul 26, 2019

Fair enough to me, maybe we should recommend Windows users to install with msvc.

And before upstream fix this problem, and if I have enough free time, I'd like to try parse .git by hand, with that, less compile time and less dependencies.

If I have enough free time……

@bjgill
Copy link
Collaborator

bjgill commented Aug 1, 2019

OK, thanks. I'm happy for this to go in as-is, then. You'll just need to remove the gnu targets from https://github.com/killercup/cargo-edit/blob/master/appveyor.yml#L12 to get CI to pass.

@DCjanus DCjanus changed the title WIP: Query crate versions from local registry index rather than HTTP API Query crate versions from local registry index rather than HTTP API Aug 3, 2019
@DCjanus
Copy link
Contributor Author

DCjanus commented Aug 7, 2019

@ordian Hi, I just resloved some conflict and force pushed, would you mind take a look.

@ordian
Copy link
Collaborator

ordian commented Aug 7, 2019

@DCjanus hey, thank you!

Travis CI failure on beta seems spurious, so let's get this merged.
bors r+

bors bot added a commit that referenced this pull request Aug 7, 2019
317: Query crate versions from local registry index rather than HTTP API r=ordian a=DCjanus

Close #311 

Co-authored-by: DCjanus <[email protected]>
@bors
Copy link
Contributor

bors bot commented Aug 7, 2019

@bors bors bot merged commit 1193902 into killercup:master Aug 7, 2019
@killercup killercup mentioned this pull request Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query latest version of crates from local registry index rather than HTTP API
3 participants