(connection_state: state::Connection)
| 24 | } |
| 25 | |
| 26 | pub fn dispatch(connection_state: state::Connection) -> DispatchFuture { |
| 27 | use self::ErrorReason::RepoPathNotSet; |
| 28 | use error::protocol::{Error, ProcessError::{Encoding, Failed}}; |
| 29 | |
| 30 | match connection_state.repo_path.clone() { |
| 31 | Some(repo_path) => Box::new( |
| 32 | git::new_command_with_repo_path(&repo_path) |
| 33 | .arg("status") |
| 34 | .arg("--porcelain=v2") |
| 35 | .arg("--untracked-files") |
| 36 | .output_async() |
| 37 | .then(|result| match result { |
| 38 | Ok(output) => match str::from_utf8(&output.stdout) { |
| 39 | Ok(output) => future::ok((String::from(output), connection_state)), |
| 40 | Err(_) => future::err((Error::Process(Encoding), connection_state)), |
| 41 | }, |
| 42 | Err(_) => future::err((Error::Process(Failed), connection_state)), |
| 43 | }) |
| 44 | .and_then(|(result, connection_state)| -> DispatchFuture { |
| 45 | if result.len() == 0 { |
| 46 | return Box::new(send_message( |
| 47 | connection_state, |
| 48 | OutboundMessage::Success { status: StatusResult::new() } |
| 49 | )); |
| 50 | } |
| 51 | |
| 52 | match parse_git_status(&result) { |
| 53 | Ok(status) => Box::new(send_message( |
| 54 | connection_state, |
| 55 | OutboundMessage::Success { status }, |
| 56 | )), |
| 57 | Err(e) => Box::new(future::err((e, connection_state))), |
| 58 | } |
| 59 | }), |
| 60 | ), |
| 61 | None => Box::new(send_message( |
| 62 | connection_state, |
| 63 | OutboundMessage::Error(RepoPathNotSet), |
| 64 | )), |
| 65 | } |
| 66 | } |
nothing calls this directly
no test coverage detected