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

Modernize all the things #129

Merged
merged 2 commits into from
Jul 1, 2017
Merged

Modernize all the things #129

merged 2 commits into from
Jul 1, 2017

Conversation

ordian
Copy link
Collaborator

@ordian ordian commented Jun 29, 2017

Sorry, my commits were squashed during stashing.

  • curl is replaced with reqwest
  • added structs instead of json::Value
  • try! is replaced with ?

@ordian ordian force-pushed the modernize branch 4 times, most recently from 6c053c5 to 66a0bcd Compare June 29, 2017 04:08
Copy link
Owner

@killercup killercup left a comment

Choose a reason for hiding this comment

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

Thanks!

So, I was pretty annoyed when I saw one single commit with +490 −279 stats… but luckily 267 of these lines are Cargo.lock and whole bunch are just try->?, so it's okay. It'll still take me a while to read through ti, though 😅

But before I do that: What's you motivation for switching to reqwest? I'm totally fine with having less C-based dependencies but I'll need more reason than that. :)

Does this:

@@ -72,8 +73,8 @@ dependencies (version set to "*").
"#;

fn handle_add(args: &Args) -> Result<(), Box<Error>> {
let mut manifest = try!(Manifest::open(&args.flag_manifest_path.as_ref().map(|s| &s[..])));
let deps = try!(args.parse_dependencies());
let mut manifest = Manifest::open(&args.flag_manifest_path.as_ref().map(|s| &s[..]))?;
Copy link
Owner

Choose a reason for hiding this comment

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

Memo to self: Hm, I think I know a better way to get this working by now, .as_ref().map(|s| &s[..]) looks quite ugly.

@@ -247,6 +232,29 @@ quick_error! {
}
}

macro_rules! get_crate_name_from_repository {
Copy link
Owner

Choose a reason for hiding this comment

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

Nice touch with the macro, but… can we make that a function with a signature like (repo: &str, matcher: &Regex, url_template: Fn(user: &str, repo: &str) -> String)?

}

quick_error! {
#[derive(Debug)]
pub enum FetchVersionError {
Curl(err: curl::Error) {
Reqwest(err: reqwest::Error) {
from()
description("Curl error")
display("Curl error: {}", err)
Copy link
Owner

Choose a reason for hiding this comment

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

Curl -> HTTP request

@killercup
Copy link
Owner

Also cc @bjgill who just updated to curl 0.4

@ordian ordian force-pushed the modernize branch 6 times, most recently from abc8bf5 to e6c224b Compare June 29, 2017 12:54
@ordian
Copy link
Collaborator Author

ordian commented Jun 29, 2017

What's you motivation for switching to reqwest?

Reqwest should work on windows (although I can't test it now) and is more concise than curl.

Allow us to specify a request timeout?

Yup.

Can we get nice error messages?

Not sure about that, but I hope so.

@bjgill
Copy link
Collaborator

bjgill commented Jun 30, 2017

I was largely updating curl in the hopes that it'd then respect the http_proxy environment variable and fix #110 fully, though I haven't worked out how to test that.

It looks as if reqwest has recently added proxy support (seanmonstar/reqwest#152), but not (yet) released it.

@killercup
Copy link
Owner

killercup commented Jun 30, 2017

Do you think it's a good idea to switch to reqwest, @bjgill? I'm kinda indifferent about it at the moment and would merge this because it also does other good stuff.

@ordian merging the clippy thing resulted in merge conflicts here.

})?;

fn get_default_timeout() -> Duration {
Duration::from_secs(10)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think 10 seconds for the timeout is a sensible default?

Copy link
Owner

Choose a reason for hiding this comment

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

10 seconds sounds good. What's the error message we get when the timeout was hit?

(Also, can you add new changes as separate commits in the future? We can always squash them later.)

Copy link
Collaborator Author

@ordian ordian Jun 30, 2017

Choose a reason for hiding this comment

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

We will get FetchVersionError::Reqwest "Https error: timed out"
(Sorry about squashing)

@bjgill
Copy link
Collaborator

bjgill commented Jun 30, 2017 via email

@killercup
Copy link
Owner

Alright, let's get this merged. I'll also open an issue to track/add tests for nice error output.

bors r+

bors bot added a commit that referenced this pull request Jul 1, 2017
129: Modernize all the things r=killercup

Sorry, my commits were squashed during stashing.

- curl is replaced with reqwest
- added structs instead of json::Value
- try! is replaced with ?
@bors
Copy link
Contributor

bors bot commented Jul 1, 2017

Build succeeded

@bors bors bot merged commit d52efee into killercup:master Jul 1, 2017
@ordian ordian deleted the modernize branch July 1, 2017 13:25
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.

3 participants