Switch to using Uuid::nil() and fix test

This commit is contained in:
Jonathan Turner
2019-09-18 19:05:33 +12:00
parent 2cf7249794
commit 72e6222992
10 changed files with 54 additions and 48 deletions

View File

@ -113,10 +113,7 @@ fn is_single_origined_text_value(input: &Vec<Tagged<Value>>) -> bool {
if let Tagged {
item: Value::Primitive(Primitive::String(_)),
tag: Tag {
origin: Some(origin),
..
},
tag: Tag { origin, .. },
} = input[0]
{
origin != uuid::Uuid::nil()

View File

@ -75,10 +75,10 @@ impl PerItemCommand for Enter {
)
.await.unwrap();
if let Some(uuid) = contents_tag.origin {
if contents_tag.origin != uuid::Uuid::nil() {
// If we have loaded something, track its source
yield ReturnSuccess::action(CommandAction::AddSpanSource(
uuid,
contents_tag.origin,
span_source,
));
}

View File

@ -76,10 +76,10 @@ fn run(
file_extension.or(path_str.split('.').last().map(String::from))
};
if let Some(uuid) = contents_tag.origin {
if contents_tag.origin != uuid::Uuid::nil() {
// If we have loaded something, track its source
yield ReturnSuccess::action(CommandAction::AddSpanSource(
uuid,
contents_tag.origin,
span_source,
));
}
@ -158,7 +158,7 @@ pub async fn fetch(
})?),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
)),
@ -173,7 +173,7 @@ pub async fn fetch(
})?),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
)),
@ -190,7 +190,7 @@ pub async fn fetch(
Value::binary(buf),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
))
@ -206,7 +206,7 @@ pub async fn fetch(
})?),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
)),
@ -223,7 +223,7 @@ pub async fn fetch(
Value::binary(buf),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
))
@ -239,7 +239,7 @@ pub async fn fetch(
})?),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
)),
@ -266,7 +266,7 @@ pub async fn fetch(
})?),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
))
@ -276,7 +276,7 @@ pub async fn fetch(
Value::string(format!("Not yet supported MIME type: {} {}", ty, sub_ty)),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
)),
@ -287,7 +287,7 @@ pub async fn fetch(
Value::string(format!("No content type found")),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::Url(location.to_string()),
)),

View File

@ -77,10 +77,10 @@ fn run(
file_extension.or(path_str.split('.').last().map(String::from))
};
if let Some(uuid) = contents_tag.origin {
if contents_tag.origin != uuid::Uuid::nil() {
// If we have loaded something, track its source
yield ReturnSuccess::action(CommandAction::AddSpanSource(
uuid,
contents_tag.origin,
span_source,
));
}
@ -147,7 +147,7 @@ pub async fn fetch(
Value::string(s),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
)),
@ -166,7 +166,7 @@ pub async fn fetch(
Value::string(s),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
)),
@ -175,7 +175,7 @@ pub async fn fetch(
Value::binary(bytes),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
)),
@ -186,7 +186,7 @@ pub async fn fetch(
Value::binary(bytes),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
))
@ -204,7 +204,7 @@ pub async fn fetch(
Value::string(s),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
)),
@ -213,7 +213,7 @@ pub async fn fetch(
Value::binary(bytes),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
)),
@ -224,7 +224,7 @@ pub async fn fetch(
Value::binary(bytes),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
))
@ -235,7 +235,7 @@ pub async fn fetch(
Value::binary(bytes),
Tag {
span,
origin: Some(Uuid::new_v4()),
origin: Uuid::new_v4(),
},
SpanSource::File(cwd.to_string_lossy().to_string()),
)),

View File

@ -85,10 +85,10 @@ fn run(
file_extension.or(path_str.split('.').last().map(String::from))
};
if let Some(uuid) = contents_tag.origin {
if contents_tag.origin != uuid::Uuid::nil() {
// If we have loaded something, track its source
yield ReturnSuccess::action(CommandAction::AddSpanSource(
uuid,
contents_tag.origin,
span_source,
));
}

View File

@ -136,7 +136,7 @@ fn save(
// If there is no filename, check the metadata for the origin filename
if input.len() > 0 {
let origin = input[0].origin();
match origin.and_then(|x| source_map.get(&x)) {
match source_map.get(&origin) {
Some(path) => match path {
SpanSource::File(file) => {
full_path.push(Path::new(file));

View File

@ -42,7 +42,7 @@ fn tags(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream,
dict.insert("end", Value::int(span.end as i64));
tags.insert_tagged("span", dict.into_tagged_value());
match origin.and_then(|x| source_map.get(&x)) {
match source_map.get(&origin) {
Some(SpanSource::File(source)) => {
tags.insert("origin", Value::string(source));
}