Build git metadata for the change's unhashed field.
(
&self,
parsed: &ParsedCommit,
is_empty: bool,
is_merge: bool,
)
| 3559 | |
| 3560 | /// Build git metadata for the change's unhashed field. |
| 3561 | fn build_git_metadata( |
| 3562 | &self, |
| 3563 | parsed: &ParsedCommit, |
| 3564 | is_empty: bool, |
| 3565 | is_merge: bool, |
| 3566 | ) -> serde_json::Value { |
| 3567 | let mut git = serde_json::json!({ |
| 3568 | "repository": self.options.repo_name, |
| 3569 | "sha": parsed.git_sha, |
| 3570 | "short_sha": parsed.short_sha, |
| 3571 | }); |
| 3572 | |
| 3573 | let diff_files: Vec<serde_json::Value> = parsed |
| 3574 | .files |
| 3575 | .iter() |
| 3576 | .filter_map(|file| { |
| 3577 | file.diff_lines.as_ref().map(|lines| { |
| 3578 | serde_json::json!({ |
| 3579 | "path": file.path, |
| 3580 | "old_path": file.old_path, |
| 3581 | "operation": match file.operation { |
| 3582 | FileOperation::Added => "added", |
| 3583 | FileOperation::Modified => "modified", |
| 3584 | FileOperation::Deleted => "deleted", |
| 3585 | FileOperation::Renamed => "renamed", |
| 3586 | FileOperation::Copied => "copied", |
| 3587 | }, |
| 3588 | "lines": lines, |
| 3589 | }) |
| 3590 | }) |
| 3591 | }) |
| 3592 | .collect(); |
| 3593 | |
| 3594 | if !diff_files.is_empty() { |
| 3595 | git["diff_lines"] = serde_json::Value::Array(diff_files); |
| 3596 | } |
| 3597 | |
| 3598 | if is_empty { |
| 3599 | git["empty_commit"] = serde_json::json!(true); |
| 3600 | } |
| 3601 | if is_merge { |
| 3602 | git["empty_merge"] = serde_json::json!(true); |
| 3603 | } |
| 3604 | |
| 3605 | serde_json::json!({ "git": git }) |
| 3606 | } |
| 3607 | |
| 3608 | // ═══════════════════════════════════════════════════════════════════════ |
| 3609 | // Post-Import Classification |
no test coverage detected