From b0c77b4446d0f51b19b778dc1d8848a4ab4348d4 Mon Sep 17 00:00:00 2001 From: Sam Rijs Date: Sun, 11 Feb 2018 18:53:26 +1100 Subject: [PATCH] filter out glob members from workspace --- src/engine/machines/crawler.rs | 23 +++++++++++++++++++++-- src/interactors/github.rs | 10 +++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/engine/machines/crawler.rs b/src/engine/machines/crawler.rs index 6843eb9..8058fed 100644 --- a/src/engine/machines/crawler.rs +++ b/src/engine/machines/crawler.rs @@ -42,13 +42,17 @@ impl ManifestCrawler { }, CrateManifest::Workspace { members } => { for mut member in members { - output.paths_of_interest.push(path.clone().join(member)); + if !member.ends_with("*") { + output.paths_of_interest.push(path.clone().join(member)); + } } }, CrateManifest::Mixed { name, deps, members } => { self.leaf_crates.insert(name, deps); for mut member in members { - output.paths_of_interest.push(path.clone().join(member)); + if !member.ends_with("*") { + output.paths_of_interest.push(path.clone().join(member)); + } } } } @@ -134,6 +138,21 @@ members = [ assert_eq!(step_output.paths_of_interest[2].to_str().unwrap(), "/contrib/"); } + #[test] + fn glob_workspace_manifest() { + let manifest = r#" +[workspace] +members = [ + "lib/", + "tests/*", +] +"#; + let mut crawler = ManifestCrawler::new(); + let step_output = crawler.step("/".into(), manifest.to_string()).unwrap(); + assert_eq!(step_output.paths_of_interest.len(), 1); + assert_eq!(step_output.paths_of_interest[0].to_str().unwrap(), "/lib/"); + } + #[test] fn mixed_package_and_workspace_manifest() { let futures_manifest = r#" diff --git a/src/interactors/github.rs b/src/interactors/github.rs index b87d0f5..fd4027e 100644 --- a/src/interactors/github.rs +++ b/src/interactors/github.rs @@ -2,7 +2,7 @@ use std::path::Path; use failure::Error; use futures::{Future, IntoFuture, Stream, future}; -use hyper::{Error as HyperError, Method, Request, Response}; +use hyper::{Error as HyperError, Method, Request, Response, Uri}; use hyper::header::UserAgent; use tokio_service::Service; use serde_json; @@ -22,15 +22,15 @@ pub fn retrieve_file_at_path>(service: S, repo_path: &RepoPath repo_path.qual.as_ref(), repo_path.name.as_ref(), path_str - ).parse().into_future().from_err(); + ).parse::().into_future().from_err(); uri_future.and_then(move |uri| { - let request = Request::new(Method::Get, uri); + let request = Request::new(Method::Get, uri.clone()); - service.call(request).from_err().and_then(|response| { + service.call(request).from_err().and_then(move |response| { let status = response.status(); if !status.is_success() { - future::Either::A(future::err(format_err!("Status code: {}", status))) + future::Either::A(future::err(format_err!("Status code {} for URI {}", status, uri))) } else { let body_future = response.body().concat2().from_err(); let decode_future = body_future