MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / patch_project_settings

Function patch_project_settings

src/dashboard/settings_api.rs:51–95  ·  view source on GitHub ↗
(
    State(state): State<DashboardState>,
    Json(patch): Json<Value>,
)

Source from the content-addressed store, hash-verified

49}
50
51pub(crate) async fn patch_project_settings(
52 State(state): State<DashboardState>,
53 Json(patch): Json<Value>,
54) -> ApiResult {
55 let patch = serde_json::from_value::<ProjectSettingsPatch>(patch)
56 .map_err(|err| patch_shape_error("project settings", &err))?;
57
58 let mut errors = Vec::new();
59 if let Some(globs) = &patch.include {
60 validate_globs("include", globs, &mut errors);
61 }
62 if let Some(globs) = &patch.exclude {
63 validate_globs("exclude", globs, &mut errors);
64 }
65 if patch.max_file_size == Some(0) {
66 errors.push(validation_error(
67 "max_file_size",
68 "max_file_size must be at least 1 byte",
69 ));
70 }
71 if !errors.is_empty() {
72 return Err(validation_failed(&errors));
73 }
74
75 let current = load_config(&state.project_root).map_err(|err| internal_error(&err))?;
76 let updated = TraceDecayConfig {
77 include: patch.include.unwrap_or_else(|| current.include.clone()),
78 exclude: patch.exclude.unwrap_or_else(|| current.exclude.clone()),
79 max_file_size: patch.max_file_size.unwrap_or(current.max_file_size),
80 extract_docstrings: patch
81 .extract_docstrings
82 .unwrap_or(current.extract_docstrings),
83 track_call_sites: patch.track_call_sites.unwrap_or(current.track_call_sites),
84 git_ignore: patch.git_ignore.unwrap_or(current.git_ignore),
85 ..current.clone()
86 };
87 let resync_recommended = updated != current;
88 if resync_recommended {
89 save_config(&state.project_root, &updated).map_err(|err| internal_error(&err))?;
90 }
91
92 let mut payload = settings_payload(&state).await?;
93 payload["resync_recommended"] = json!(resync_recommended);
94 Ok(Json(payload))
95}
96
97pub(crate) async fn patch_user_settings(
98 State(state): State<DashboardState>,

Callers

nothing calls this directly

Calls 10

patch_shape_errorFunction · 0.85
validate_globsFunction · 0.85
validation_errorFunction · 0.85
validation_failedFunction · 0.85
load_configFunction · 0.85
save_configFunction · 0.85
settings_payloadFunction · 0.85
pushMethod · 0.80
internal_errorFunction · 0.70
is_emptyMethod · 0.45

Tested by

no test coverage detected