Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
refactor: move request reading into a function
Lars Wirzenius committed 2 years ago
commit 2a88f67fb49efe7c170e89a35d61ce587890bf27
parent b7115d8
1 file changed +8 -2
modified src/main.rs
@@ -58,8 +58,7 @@ fn fallible_main() -> Result<(), NativeError> {
    let profile = Profile::load().map_err(NativeError::LoadProfile)?;
    let storage = profile.storage.path();

-
    let req = Request::from_reader(std::io::stdin()).map_err(NativeError::ReadRequest)?;
-
    debug!("request: {:#?}", req);
+
    let req = read_request()?;

    if let Request::Trigger { repo, commit } = req {
        info!("Request to trigger CI on {}, {}", repo, commit);
@@ -90,6 +89,13 @@ fn mkdir_run(config: &Config) -> Result<(Uuid, PathBuf), NativeError> {
    Ok((run_id, run_dir))
}

+
/// Read a request from stdin.
+
fn read_request() -> Result<Request, NativeError> {
+
    let req = Request::from_reader(std::io::stdin()).map_err(NativeError::ReadRequest)?;
+
    debug!("request: {:#?}", req);
+
    Ok(req)
+
}
+

/// Perform the CI run.
fn run(
    run_id: Uuid,