refactor(config): PR #207 회차 1 반영 — from_file toml::Value 단일 파싱
This commit is contained in:
@@ -964,14 +964,16 @@ impl Config {
|
|||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// p9-fb-25: probe for the legacy `workspace.include` key — if
|
// raw `toml::Value` 를 한 번만 파싱해 (1) legacy `workspace.include`
|
||||||
// present, emit a one-shot deprecation warning. Detection uses
|
// deprecation probe (p9-fb-25) 와 (2) `schema_version` 감지(v3 자동변환)
|
||||||
// raw `toml::Value` lookup; the warning fires via a process-
|
// 에 함께 쓴다 — config load 는 매 CLI 호출마다 일어나므로 파싱 1회로.
|
||||||
// level OnceLock so a long-running TUI / CLI run doesn't spam
|
let probe = toml::from_str::<toml::Value>(&text).ok();
|
||||||
// the log on every Config::load.
|
|
||||||
if let Ok(value) = toml::from_str::<toml::Value>(&text) {
|
// p9-fb-25: legacy `workspace.include` 키가 있으면 일회성 deprecation
|
||||||
if value
|
// 경고(process-level OnceLock 로 장기 실행 시 로그 도배 방지).
|
||||||
.get("workspace")
|
if probe
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|v| v.get("workspace"))
|
||||||
.and_then(|v| v.get("include"))
|
.and_then(|v| v.get("include"))
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
@@ -984,15 +986,14 @@ impl Config {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// v3: 파일의 schema_version 이 CURRENT 보다 낮으면 메모리에서 변환한다
|
// v3: 파일의 schema_version 이 CURRENT 보다 낮으면 메모리에서 변환한다
|
||||||
// (디스크 미변경 — 파일 갱신은 `kebab config migrate`). 미변환 v2 파일도
|
// (디스크 미변경 — 파일 갱신은 `kebab config migrate`). 미변환 v2 파일도
|
||||||
// 설정 유실 없이 로드(불변식 #3). non-additive relocation(v2→v3) 은
|
// 설정 유실 없이 로드(불변식 #3). non-additive relocation(v2→v3) 은
|
||||||
// serde default forward-compat 로는 커버 안 되므로 반드시 거쳐야 한다.
|
// serde default forward-compat 로는 커버 안 되므로 반드시 거쳐야 한다.
|
||||||
let parse_text = {
|
let parse_text = {
|
||||||
let from = toml::from_str::<toml::Value>(&text)
|
let from = probe
|
||||||
.ok()
|
.as_ref()
|
||||||
.and_then(|v| v.get("schema_version").and_then(toml::Value::as_integer))
|
.and_then(|v| v.get("schema_version").and_then(toml::Value::as_integer))
|
||||||
.unwrap_or(1) as u32;
|
.unwrap_or(1) as u32;
|
||||||
if from < crate::migrate::CURRENT_SCHEMA_VERSION {
|
if from < crate::migrate::CURRENT_SCHEMA_VERSION {
|
||||||
|
|||||||
Reference in New Issue
Block a user