refactor: move request reading into a function

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2023-12-14 17:47:42 +02:00
parent b7115d85c4
commit 2a88f67fb4
+8 -2
View File
@@ -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,