netsky 0.2.0

netsky CLI: the viable system launcher and subcommand dispatcher
Documentation
use chrono::Utc;
use netsky_db::GitOperationRecord;

use crate::observability;

#[allow(clippy::too_many_arguments)]
pub fn record_git_op(
    operation: &str,
    repo: &str,
    branch: Option<&str>,
    remote: Option<&str>,
    from_sha: Option<&str>,
    to_sha: Option<&str>,
    status: &str,
    detail_json: Option<&str>,
) -> netsky_core::Result<()> {
    if operation.trim().is_empty() {
        netsky_core::bail!("operation must not be empty");
    }
    if repo.trim().is_empty() {
        netsky_core::bail!("repo must not be empty");
    }
    if status.trim().is_empty() {
        netsky_core::bail!("status must not be empty");
    }
    if let Some(raw) = detail_json {
        let _: serde_json::Value = serde_json::from_str(raw)?;
    }
    observability::record_git_operation(GitOperationRecord {
        ts_utc: Utc::now(),
        operation,
        repo,
        branch,
        remote,
        from_sha,
        to_sha,
        status,
        detail_json,
    });
    Ok(())
}