MCPcopy Create free account
hub / github.com/AI45Lab/Code / normalize_git_args

Function normalize_git_args

sdk/node/src/lib.rs:1019–1045  ·  view source on GitHub ↗
(mut args: serde_json::Value)

Source from the content-addressed store, hash-verified

1017}
1018
1019fn 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
1047fn timeout_ms_to_secs(timeout_ms: u64) -> u64 {
1048 timeout_ms.div_ceil(1000).max(1)

Callers 1

git_commandMethod · 0.70

Calls 1

removeMethod · 0.80

Tested by

no test coverage detected