Build git metadata for the change's unhashed field.
(
&self,
parsed: &ParsedCommit,
is_empty: bool,
is_merge: bool,
)
| 3351 | |
| 3352 | /// Build git metadata for the change's unhashed field. |
| 3353 | fn build_git_metadata( |
| 3354 | &self, |
| 3355 | parsed: &ParsedCommit, |
| 3356 | is_empty: bool, |
| 3357 | is_merge: bool, |
| 3358 | ) -> serde_json::Value { |
| 3359 | let mut git = serde_json::json!({ |
| 3360 | "repository": self.options.repo_name, |
| 3361 | "sha": parsed.git_sha, |
| 3362 | "short_sha": parsed.short_sha, |
| 3363 | }); |
| 3364 | |
| 3365 | let diff_files: Vec<serde_json::Value> = parsed |
| 3366 | .files |
| 3367 | .iter() |
| 3368 | .filter_map(|file| { |
| 3369 | file.diff_lines.as_ref().map(|lines| { |
| 3370 | serde_json::json!({ |
| 3371 | "path": file.path, |
| 3372 | "old_path": file.old_path, |
| 3373 | "operation": match file.operation { |
| 3374 | FileOperation::Added => "added", |
| 3375 | FileOperation::Modified => "modified", |
| 3376 | FileOperation::Deleted => "deleted", |
| 3377 | FileOperation::Renamed => "renamed", |
| 3378 | FileOperation::Copied => "copied", |
| 3379 | }, |
| 3380 | "lines": lines, |
| 3381 | }) |
| 3382 | }) |
| 3383 | }) |
| 3384 | .collect(); |
| 3385 | |
| 3386 | if !diff_files.is_empty() { |
| 3387 | git["diff_lines"] = serde_json::Value::Array(diff_files); |
| 3388 | } |
| 3389 | |
| 3390 | if is_empty { |
| 3391 | git["empty_commit"] = serde_json::json!(true); |
| 3392 | } |
| 3393 | if is_merge { |
| 3394 | git["empty_merge"] = serde_json::json!(true); |
| 3395 | } |
| 3396 | |
| 3397 | serde_json::json!({ "git": git }) |
| 3398 | } |
| 3399 | |
| 3400 | // ═══════════════════════════════════════════════════════════════════════ |
| 3401 | // Post-Import Classification |
no test coverage detected