Skip to content

Commit 7040d41

Browse files
committed
rename metadata_version to format_version
The new name is more accurate.
1 parent cb68c05 commit 7040d41

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/bootstrap/metrics.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use sysinfo::{CpuExt, System, SystemExt};
1919
// Versions:
2020
// 0: initial version
2121
// 1: replaced JsonNode::Test with JsonNode::TestSuite
22-
const CURRENT_METADATA_VERSION: usize = 1;
22+
const CURRENT_FORMAT_VERSION: usize = 1;
2323

2424
pub(crate) struct BuildMetrics {
2525
state: RefCell<MetricsState>,
@@ -151,15 +151,15 @@ impl BuildMetrics {
151151
// previous invocations are still present in the resulting file.
152152
let mut invocations = match std::fs::read(&dest) {
153153
Ok(contents) => {
154-
// We first parse just the metadata_version field to have the check succeed even if
154+
// We first parse just the format_version field to have the check succeed even if
155155
// the rest of the contents are not valid anymore.
156-
let version: OnlyMetadataVersion = t!(serde_json::from_slice(&contents));
157-
if version.metadata_version == CURRENT_METADATA_VERSION {
156+
let version: OnlyFormatVersion = t!(serde_json::from_slice(&contents));
157+
if version.format_version == CURRENT_FORMAT_VERSION {
158158
t!(serde_json::from_slice::<JsonRoot>(&contents)).invocations
159159
} else {
160160
println!(
161161
"warning: overriding existing build/metrics.json, as it's not \
162-
compatible with build metrics format version {CURRENT_METADATA_VERSION}."
162+
compatible with build metrics format version {CURRENT_FORMAT_VERSION}."
163163
);
164164
Vec::new()
165165
}
@@ -181,8 +181,7 @@ impl BuildMetrics {
181181
children: steps.into_iter().map(|step| self.prepare_json_step(step)).collect(),
182182
});
183183

184-
let json =
185-
JsonRoot { metadata_version: CURRENT_METADATA_VERSION, system_stats, invocations };
184+
let json = JsonRoot { format_version: CURRENT_FORMAT_VERSION, system_stats, invocations };
186185

187186
t!(std::fs::create_dir_all(dest.parent().unwrap()));
188187
let mut file = BufWriter::new(t!(File::create(&dest)));
@@ -234,7 +233,7 @@ struct StepMetrics {
234233
#[serde(rename_all = "snake_case")]
235234
struct JsonRoot {
236235
#[serde(default)] // For version 0 the field was not present.
237-
metadata_version: usize,
236+
format_version: usize,
238237
system_stats: JsonInvocationSystemStats,
239238
invocations: Vec<JsonInvocation>,
240239
}
@@ -322,7 +321,7 @@ struct JsonStepSystemStats {
322321
}
323322

324323
#[derive(Deserialize)]
325-
struct OnlyMetadataVersion {
324+
struct OnlyFormatVersion {
326325
#[serde(default)] // For version 0 the field was not present.
327-
metadata_version: usize,
326+
format_version: usize,
328327
}

0 commit comments

Comments
 (0)