| 1017 | } |
| 1018 | |
| 1019 | fn normalize_git_args(mut args: serde_json::Value) -> napi::Result<serde_json::Value> { |
| 1020 | let obj = args |
| 1021 | .as_object_mut() |
| 1022 | .ok_or_else(|| napi::Error::from_reason("git options must be an object"))?; |
| 1023 | |
| 1024 | if !obj.contains_key("command") { |
| 1025 | return Err(napi::Error::from_reason( |
| 1026 | "git options must include a command field", |
| 1027 | )); |
| 1028 | } |
| 1029 | |
| 1030 | for (from, to) in [ |
| 1031 | ("newBranch", "new_branch"), |
| 1032 | ("maxCount", "max_count"), |
| 1033 | ("includeUntracked", "include_untracked"), |
| 1034 | ] { |
| 1035 | if let Some(value) = obj.remove(from) { |
| 1036 | obj.entry(to.to_string()).or_insert(value); |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | if let Some(value) = obj.remove("reference") { |
| 1041 | obj.entry("ref".to_string()).or_insert(value); |
| 1042 | } |
| 1043 | |
| 1044 | Ok(args) |
| 1045 | } |
| 1046 | |
| 1047 | fn timeout_ms_to_secs(timeout_ms: u64) -> u64 { |
| 1048 | timeout_ms.div_ceil(1000).max(1) |