Build git metadata for the change's unhashed field.
(
&self,
parsed: &ParsedCommit,
is_empty: bool,
is_merge: bool,
)
| 3323 | |
| 3324 | /// Build git metadata for the change's unhashed field. |
| 3325 | fn build_git_metadata( |
| 3326 | &self, |
| 3327 | parsed: &ParsedCommit, |
| 3328 | is_empty: bool, |
| 3329 | is_merge: bool, |
| 3330 | ) -> serde_json::Value { |
| 3331 | let mut git = serde_json::json!({ |
| 3332 | "repository": self.options.repo_name, |
| 3333 | "sha": parsed.git_sha, |
| 3334 | "short_sha": parsed.short_sha, |
| 3335 | }); |
| 3336 | |
| 3337 | let diff_files: Vec<serde_json::Value> = parsed |
| 3338 | .files |
| 3339 | .iter() |
| 3340 | .filter_map(|file| { |
| 3341 | file.diff_lines.as_ref().map(|lines| { |
| 3342 | serde_json::json!({ |
| 3343 | "path": file.path, |
| 3344 | "old_path": file.old_path, |
| 3345 | "operation": match file.operation { |
| 3346 | FileOperation::Added => "added", |
| 3347 | FileOperation::Modified => "modified", |
| 3348 | FileOperation::Deleted => "deleted", |
| 3349 | FileOperation::Renamed => "renamed", |
| 3350 | FileOperation::Copied => "copied", |
| 3351 | }, |
| 3352 | "lines": lines, |
| 3353 | }) |
| 3354 | }) |
| 3355 | }) |
| 3356 | .collect(); |
| 3357 | |
| 3358 | if !diff_files.is_empty() { |
| 3359 | git["diff_lines"] = serde_json::Value::Array(diff_files); |
| 3360 | } |
| 3361 | |
| 3362 | if is_empty { |
| 3363 | git["empty_commit"] = serde_json::json!(true); |
| 3364 | } |
| 3365 | if is_merge { |
| 3366 | git["empty_merge"] = serde_json::json!(true); |
| 3367 | } |
| 3368 | |
| 3369 | serde_json::json!({ "git": git }) |
| 3370 | } |
| 3371 | |
| 3372 | // ═══════════════════════════════════════════════════════════════════════ |
| 3373 | // Post-Import Classification |
no test coverage detected