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

Function dispatch

gitrs_server/src/dispatch/git_command/log/mod.rs:26–63  ·  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::{RepoHasNoCommits, RepoPathNotSet};
28 use error::protocol::{Error, ProcessError::{Encoding, Failed, Parsing}};
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("log")
34 .arg("--format=sha %H%nparents %P%nauthor %an%nemail %ae%ndate %ai%nsummary %s%ndescription %b%x00%x00")
35 .output_async()
36 .then(|result| match result {
37 Ok(output) => match str::from_utf8(&output.stdout) {
38 Ok(output) => future::ok((String::from(output), connection_state)),
39 Err(_) => future::err((Error::Process(Encoding), connection_state)),
40 },
41 Err(_) => future::err((Error::Process(Failed), connection_state)),
42 })
43 .and_then(|(result, connection_state)| -> DispatchFuture {
44 if result.len() == 0 {
45 return Box::new(send_message(
46 connection_state,
47 OutboundMessage::Error(RepoHasNoCommits)
48 ));
49 }
50
51 match parse_log(&result) {
52 Ok(log) => Box::new(
53 send_message(connection_state, OutboundMessage::Success { log })
54 ),
55 Err(_) => Box::new(
56 future::err((Error::Process(Parsing), connection_state))
57 ),
58 }
59 }),
60 ),
61 None => Box::new(send_message(connection_state, OutboundMessage::Error(RepoPathNotSet))),
62 }
63}

Callers

nothing calls this directly

Calls 4

send_messageFunction · 0.85
ErrorEnum · 0.85
parse_logFunction · 0.85

Tested by

no test coverage detected