Skip to content

Commit

Permalink
Made cargo plugin use a user agent when talking to crates.io. Fixes r…
Browse files Browse the repository at this point in the history
  • Loading branch information
ibabushkin committed May 19, 2019
1 parent 8a0aa51 commit 0f26377
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ path = "src/bin/rust_semverver.rs"

[dependencies]
cargo = "0.32"
crates-io = "0.20"
crates-io = "0.23"
curl = "0.4.21"
env_logger = "0.6"
failure = "0.1"
log = "0.4"
Expand Down
7 changes: 6 additions & 1 deletion src/bin/cargo_semver.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#![feature(rustc_private)]
#![feature(set_stdio)]

extern crate curl;
extern crate getopts;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;

use cargo::core::{Package, PackageId, PackageSet, Source, SourceId, SourceMap, Workspace};
use curl::easy::Easy;
use log::debug;
use std::{
env,
Expand Down Expand Up @@ -463,7 +465,10 @@ impl<'a> WorkInfo<'a> {
///
/// If no crate with the exact name is present, error out.
pub fn find_on_crates_io(crate_name: &str) -> Result<crates_io::Crate> {
let mut registry = crates_io::Registry::new("https://crates.io".to_owned(), None);
let mut handle = Easy::new();
handle.useragent(&format!("rust-semverver {}", env!("CARGO_PKG_VERSION")))?;
let mut registry =
crates_io::Registry::new_handle("https://crates.io".to_owned(), None, handle);

registry
.search(crate_name, 1)
Expand Down

0 comments on commit 0f26377

Please sign in to comment.