|
1 | 1 | use std::collections::HashMap;
|
2 | 2 | use std::collections::HashSet;
|
3 | 3 |
|
| 4 | +use gitql_ast::types::array::ArrayType; |
4 | 5 | use gitql_ast::types::boolean::BoolType;
|
5 | 6 | use gitql_ast::types::integer::IntType;
|
6 | 7 | use gitql_ast::types::text::TextType;
|
7 | 8 | use gitql_core::signature::Signature;
|
8 | 9 | use gitql_core::signature::StandardFunction;
|
| 10 | +use gitql_core::values::array::ArrayValue; |
9 | 11 | use gitql_core::values::base::Value;
|
10 | 12 | use gitql_core::values::boolean::BoolValue;
|
11 | 13 | use gitql_core::values::integer::IntValue;
|
@@ -36,6 +38,7 @@ pub(crate) fn register_diffs_functions(map: &mut HashMap<&'static str, StandardF
|
36 | 38 | diff_changes_modified_content_contains,
|
37 | 39 | );
|
38 | 40 |
|
| 41 | + map.insert("diff_changed_files", diff_changed_files); |
39 | 42 | map.insert("diff_files_count", diff_changes_files_count);
|
40 | 43 |
|
41 | 44 | map.insert("is_diff_has_file", diff_changes_contains_file);
|
@@ -91,6 +94,12 @@ pub(crate) fn register_diffs_function_signatures(map: &mut HashMap<&'static str,
|
91 | 94 | .add_parameter(Box::new(TextType)),
|
92 | 95 | );
|
93 | 96 |
|
| 97 | + map.insert( |
| 98 | + "diff_changed_files", |
| 99 | + Signature::with_return(Box::new(ArrayType::new(Box::new(TextType)))) |
| 100 | + .add_parameter(Box::new(DiffChangesType)), |
| 101 | + ); |
| 102 | + |
94 | 103 | map.insert(
|
95 | 104 | "diff_files_count",
|
96 | 105 | Signature::with_return(Box::new(IntType)).add_parameter(Box::new(DiffChangesType)),
|
@@ -217,6 +226,17 @@ fn diff_changes_modified_content_contains(values: &[Box<dyn Value>]) -> Box<dyn
|
217 | 226 | Box::new(BoolValue::new_false())
|
218 | 227 | }
|
219 | 228 |
|
| 229 | +fn diff_changed_files(values: &[Box<dyn Value>]) -> Box<dyn Value> { |
| 230 | + if let Some(changes) = values[0].as_any().downcast_ref::<DiffChangesValue>() { |
| 231 | + let mut elements: Vec<Box<dyn Value>> = vec![]; |
| 232 | + for change in changes.changes.iter() { |
| 233 | + elements.push(Box::new(TextValue::new(change.location.to_string()))); |
| 234 | + } |
| 235 | + return Box::new(ArrayValue::new(elements, Box::new(TextType))); |
| 236 | + } |
| 237 | + Box::new(ArrayValue::empty(Box::new(TextType))) |
| 238 | +} |
| 239 | + |
220 | 240 | fn diff_changes_files_count(values: &[Box<dyn Value>]) -> Box<dyn Value> {
|
221 | 241 | if let Some(changes) = values[0].as_any().downcast_ref::<DiffChangesValue>() {
|
222 | 242 | let mut unique_files: HashSet<&String> = HashSet::new();
|
|
0 commit comments