mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
Introduce InstanceContext (#270)
* Add instance context with dummy field * Remove stub field
This commit is contained in:
committed by
GitHub
parent
a48c238ed7
commit
12df80da56
@@ -43,6 +43,14 @@ pub struct InstanceMetadata {
|
||||
// TODO: Change this to be a SmallVec for performance in common cases?
|
||||
#[serde(serialize_with = "path_serializer::serialize_vec_absolute")]
|
||||
pub relevant_paths: Vec<PathBuf>,
|
||||
|
||||
/// Contains information about this instance that should persist between
|
||||
/// snapshot invocations and is generally inherited.
|
||||
///
|
||||
/// If an instance has a piece of context attached to it, then the next time
|
||||
/// that instance's instigating source is snapshotted directly, the same
|
||||
/// context will be passed into it.
|
||||
pub context: InstanceContext,
|
||||
}
|
||||
|
||||
impl InstanceMetadata {
|
||||
@@ -51,6 +59,7 @@ impl InstanceMetadata {
|
||||
ignore_unknown_instances: false,
|
||||
instigating_source: None,
|
||||
relevant_paths: Vec::new(),
|
||||
context: InstanceContext::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +83,13 @@ impl InstanceMetadata {
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn context(self, context: &InstanceContext) -> Self {
|
||||
Self {
|
||||
context: context.clone(),
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for InstanceMetadata {
|
||||
@@ -82,6 +98,15 @@ impl Default for InstanceMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct InstanceContext {}
|
||||
|
||||
impl Default for InstanceContext {
|
||||
fn default() -> Self {
|
||||
InstanceContext {}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum InstigatingSource {
|
||||
Path(#[serde(serialize_with = "path_serializer::serialize_absolute")] PathBuf),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: src/snapshot/tests/apply.rs
|
||||
expression: tree_value
|
||||
expression: tree_view
|
||||
---
|
||||
id: id-1
|
||||
name: ROOT
|
||||
@@ -12,4 +12,5 @@ properties:
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
children: []
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: src/snapshot/tests/apply.rs
|
||||
expression: tree_value
|
||||
expression: tree_view
|
||||
---
|
||||
id: id-1
|
||||
name: ROOT
|
||||
@@ -9,4 +9,5 @@ properties: {}
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
children: []
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: src/snapshot/tests/apply.rs
|
||||
expression: tree_value
|
||||
expression: tree_view
|
||||
---
|
||||
id: id-1
|
||||
name: ROOT
|
||||
@@ -12,4 +12,5 @@ properties:
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
children: []
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
source: src/snapshot/tests/apply.rs
|
||||
expression: tree_value
|
||||
expression: tree_view
|
||||
---
|
||||
id: id-1
|
||||
name: "Hello, world!"
|
||||
@@ -9,4 +9,5 @@ properties: {}
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
children: []
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -10,8 +10,9 @@ added_instances:
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context: {}
|
||||
name: New
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children: []
|
||||
updated_instances: []
|
||||
updated_instances: []
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.client.lua
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: LocalScript
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.csv
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: LocalizationTable
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.csv
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: LocalizationTable
|
||||
properties:
|
||||
|
||||
@@ -13,6 +13,7 @@ metadata:
|
||||
- /foo/init.lua
|
||||
- /foo/init.server.lua
|
||||
- /foo/init.client.lua
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
|
||||
@@ -13,6 +13,7 @@ metadata:
|
||||
- /foo/init.lua
|
||||
- /foo/init.server.lua
|
||||
- /foo/init.client.lua
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
@@ -28,6 +29,7 @@ children:
|
||||
- /foo/Child/init.lua
|
||||
- /foo/Child/init.server.lua
|
||||
- /foo/Child/init.client.lua
|
||||
context: {}
|
||||
name: Child
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
|
||||
@@ -13,6 +13,7 @@ metadata:
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
context: {}
|
||||
name: root
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.txt
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: StringValue
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo.model.json
|
||||
relevant_paths:
|
||||
- /foo.model.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: IntValue
|
||||
properties:
|
||||
@@ -20,6 +21,7 @@ children:
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
relevant_paths: []
|
||||
context: {}
|
||||
name: The Child
|
||||
class_name: StringValue
|
||||
properties: {}
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.lua
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.lua
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo/hello.project.json
|
||||
relevant_paths:
|
||||
- /foo/hello.project.json
|
||||
context: {}
|
||||
name: direct-project
|
||||
class_name: Model
|
||||
properties: {}
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo/default.project.json
|
||||
relevant_paths:
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: indirect-project
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo/other.project.json
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: path-property-override
|
||||
class_name: StringValue
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo/default.project.json
|
||||
relevant_paths:
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: children
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
@@ -25,6 +26,7 @@ children:
|
||||
ignore_unknown_instances: ~
|
||||
path: ~
|
||||
relevant_paths: []
|
||||
context: {}
|
||||
name: Child
|
||||
class_name: Model
|
||||
properties: {}
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo/other.project.json
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: path-project
|
||||
class_name: Model
|
||||
properties: {}
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo/other.project.json
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: path-child-project
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
@@ -26,6 +27,7 @@ children:
|
||||
ignore_unknown_instances: ~
|
||||
path: ~
|
||||
relevant_paths: []
|
||||
context: {}
|
||||
name: SomeChild
|
||||
class_name: Model
|
||||
properties: {}
|
||||
|
||||
@@ -11,6 +11,7 @@ metadata:
|
||||
- /foo/other.txt
|
||||
- /foo/other.meta.json
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: path-project
|
||||
class_name: StringValue
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo/default.project.json
|
||||
relevant_paths:
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: resolved-properties
|
||||
class_name: StringValue
|
||||
properties:
|
||||
|
||||
@@ -9,6 +9,7 @@ metadata:
|
||||
Path: /foo/default.project.json
|
||||
relevant_paths:
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
name: unresolved-properties
|
||||
class_name: StringValue
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /bar.server.lua
|
||||
- /bar.meta.json
|
||||
context: {}
|
||||
name: bar
|
||||
class_name: Script
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.server.lua
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: Script
|
||||
properties:
|
||||
|
||||
@@ -10,6 +10,7 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.server.lua
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
name: foo
|
||||
class_name: Script
|
||||
properties:
|
||||
|
||||
@@ -12,6 +12,7 @@ metadata:
|
||||
Path: /foo/default.project.json
|
||||
relevant_paths:
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
children:
|
||||
- id: id-2
|
||||
name: Child
|
||||
@@ -33,4 +34,5 @@ children:
|
||||
relevant_paths:
|
||||
- /foo/file.txt
|
||||
- /foo/file.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -12,6 +12,7 @@ metadata:
|
||||
Path: /foo/default.project.json
|
||||
relevant_paths:
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
children:
|
||||
- id: id-2
|
||||
name: Child
|
||||
@@ -33,4 +34,5 @@ children:
|
||||
relevant_paths:
|
||||
- /foo/file.txt
|
||||
- /foo/file.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -16,6 +16,7 @@ metadata:
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
context: {}
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
@@ -31,4 +32,5 @@ children:
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -16,6 +16,7 @@ metadata:
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
context: {}
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
@@ -31,4 +32,5 @@ children:
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -17,3 +17,4 @@ expression: redactions.redacted_yaml(changes)
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
context: {}
|
||||
|
||||
@@ -16,4 +16,5 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.txt
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -16,4 +16,5 @@ metadata:
|
||||
relevant_paths:
|
||||
- /foo.txt
|
||||
- /foo.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -16,4 +16,5 @@ metadata:
|
||||
- /foo/init.lua
|
||||
- /foo/init.server.lua
|
||||
- /foo/init.client.lua
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -17,6 +17,7 @@ metadata:
|
||||
- /foo/src/init.server.lua
|
||||
- /foo/src/init.client.lua
|
||||
- /foo/default.project.json
|
||||
context: {}
|
||||
children:
|
||||
- id: id-2
|
||||
name: hello
|
||||
@@ -32,4 +33,5 @@ children:
|
||||
relevant_paths:
|
||||
- /foo/src/hello.txt
|
||||
- /foo/src/hello.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
@@ -16,6 +16,7 @@ metadata:
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
context: {}
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
@@ -31,4 +32,5 @@ children:
|
||||
relevant_paths:
|
||||
- /root/test.lua
|
||||
- /root/test.meta.json
|
||||
context: {}
|
||||
children: []
|
||||
|
||||
Reference in New Issue
Block a user