MCPcopy Create free account
hub / github.com/Axosoft/git-rs / dispatch

Function dispatch

gitrs_server/src/dispatch/git_command/status/mod.rs:26–66  ·  view source on GitHub ↗
(connection_state: state::Connection)

Source from the content-addressed store, hash-verified

24}
25
26pub 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}

Callers

nothing calls this directly

Calls 4

send_messageFunction · 0.85
parse_git_statusFunction · 0.85
ErrorEnum · 0.85

Tested by

no test coverage detected