rename metadata_version to format_version
The new name is more accurate.
This commit is contained in:
parent
cb68c05151
commit
7040d4102f
@ -19,7 +19,7 @@
|
||||
// Versions:
|
||||
// 0: initial version
|
||||
// 1: replaced JsonNode::Test with JsonNode::TestSuite
|
||||
const CURRENT_METADATA_VERSION: usize = 1;
|
||||
const CURRENT_FORMAT_VERSION: usize = 1;
|
||||
|
||||
pub(crate) struct BuildMetrics {
|
||||
state: RefCell<MetricsState>,
|
||||
@ -151,15 +151,15 @@ pub(crate) fn persist(&self, build: &Build) {
|
||||
// previous invocations are still present in the resulting file.
|
||||
let mut invocations = match std::fs::read(&dest) {
|
||||
Ok(contents) => {
|
||||
// We first parse just the metadata_version field to have the check succeed even if
|
||||
// We first parse just the format_version field to have the check succeed even if
|
||||
// the rest of the contents are not valid anymore.
|
||||
let version: OnlyMetadataVersion = t!(serde_json::from_slice(&contents));
|
||||
if version.metadata_version == CURRENT_METADATA_VERSION {
|
||||
let version: OnlyFormatVersion = t!(serde_json::from_slice(&contents));
|
||||
if version.format_version == CURRENT_FORMAT_VERSION {
|
||||
t!(serde_json::from_slice::<JsonRoot>(&contents)).invocations
|
||||
} else {
|
||||
println!(
|
||||
"warning: overriding existing build/metrics.json, as it's not \
|
||||
compatible with build metrics format version {CURRENT_METADATA_VERSION}."
|
||||
compatible with build metrics format version {CURRENT_FORMAT_VERSION}."
|
||||
);
|
||||
Vec::new()
|
||||
}
|
||||
@ -181,8 +181,7 @@ pub(crate) fn persist(&self, build: &Build) {
|
||||
children: steps.into_iter().map(|step| self.prepare_json_step(step)).collect(),
|
||||
});
|
||||
|
||||
let json =
|
||||
JsonRoot { metadata_version: CURRENT_METADATA_VERSION, system_stats, invocations };
|
||||
let json = JsonRoot { format_version: CURRENT_FORMAT_VERSION, system_stats, invocations };
|
||||
|
||||
t!(std::fs::create_dir_all(dest.parent().unwrap()));
|
||||
let mut file = BufWriter::new(t!(File::create(&dest)));
|
||||
@ -234,7 +233,7 @@ struct StepMetrics {
|
||||
#[serde(rename_all = "snake_case")]
|
||||
struct JsonRoot {
|
||||
#[serde(default)] // For version 0 the field was not present.
|
||||
metadata_version: usize,
|
||||
format_version: usize,
|
||||
system_stats: JsonInvocationSystemStats,
|
||||
invocations: Vec<JsonInvocation>,
|
||||
}
|
||||
@ -322,7 +321,7 @@ struct JsonStepSystemStats {
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct OnlyMetadataVersion {
|
||||
struct OnlyFormatVersion {
|
||||
#[serde(default)] // For version 0 the field was not present.
|
||||
metadata_version: usize,
|
||||
format_version: usize,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user