Integrate release recovery, semantic review, coverage and Windows packaging
This commit is contained in:
@@ -52,7 +52,87 @@ pub struct Draft {
|
||||
pub value_browsers: BTreeMap<String, ValueBrowser>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct RecoveryDraft {
|
||||
original: Id,
|
||||
value: Value,
|
||||
exact_strings: bool,
|
||||
inputs: BTreeMap<String, String>,
|
||||
constructors: Vec<(String, String, Value, BTreeMap<String, String>)>,
|
||||
ports: BTreeMap<String, Value>,
|
||||
}
|
||||
|
||||
impl Draft {
|
||||
pub fn recovery_snapshot(&self) -> RecoveryDraft {
|
||||
let raw = |inputs: &BTreeMap<String, Input>| {
|
||||
inputs
|
||||
.iter()
|
||||
.map(|(path, input)| (path.clone(), input.raw.clone()))
|
||||
.collect()
|
||||
};
|
||||
RecoveryDraft {
|
||||
original: self.original,
|
||||
value: self.value.clone(),
|
||||
exact_strings: self.exact_strings,
|
||||
inputs: raw(&self.inputs),
|
||||
constructors: self
|
||||
.constructor_drafts
|
||||
.iter()
|
||||
.map(|((path, kind), (value, inputs))| {
|
||||
(path.clone(), kind.clone(), value.clone(), raw(inputs))
|
||||
})
|
||||
.collect(),
|
||||
ports: self.port_contract_drafts.clone(),
|
||||
}
|
||||
}
|
||||
pub fn from_recovery(project: &Project, saved: RecoveryDraft) -> Result<Self, String> {
|
||||
let input_count = saved.inputs.len().saturating_add(
|
||||
saved
|
||||
.constructors
|
||||
.iter()
|
||||
.map(|(_, _, _, inputs)| inputs.len())
|
||||
.sum::<usize>(),
|
||||
);
|
||||
if input_count > crate::source_workspace::LIMITS.model.max_records
|
||||
|| saved.constructors.len() > 1024
|
||||
|| saved.ports.len() > 32
|
||||
{
|
||||
return Err("Recovered property buffers exceed the supported limit.".into());
|
||||
}
|
||||
let mut draft = Self::from_project(project, saved.original)
|
||||
.ok_or("Recovered property owner no longer exists.")?;
|
||||
draft.value = saved.value;
|
||||
draft.exact_strings = saved.exact_strings;
|
||||
draft.rebuild();
|
||||
if !draft.inputs.keys().eq(saved.inputs.keys()) {
|
||||
return Err("Recovered property fields no longer match their raw buffers.".into());
|
||||
}
|
||||
for (path, raw) in saved.inputs {
|
||||
draft.input(&path, raw);
|
||||
}
|
||||
draft.constructor_drafts = saved
|
||||
.constructors
|
||||
.into_iter()
|
||||
.map(|(path, kind, value, inputs)| {
|
||||
(
|
||||
(path, kind),
|
||||
(
|
||||
value,
|
||||
inputs
|
||||
.into_iter()
|
||||
.map(|(path, raw)| {
|
||||
let editor = text_editor::Content::with_text(&raw);
|
||||
(path, Input { raw, editor })
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
draft.port_contract_drafts = saved.ports;
|
||||
Ok(draft)
|
||||
}
|
||||
pub fn from_project(project: &Project, selected: Id) -> Option<Self> {
|
||||
let (kind, value) = if selected == project.id {
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user