Build git metadata for the change's unhashed field.
(
&self,
parsed: &ParsedCommit,
is_empty: bool,
is_merge: bool,
)
| 3242 | |
| 3243 | /// Build git metadata for the change's unhashed field. |
| 3244 | fn build_git_metadata( |
| 3245 | &self, |
| 3246 | parsed: &ParsedCommit, |
| 3247 | is_empty: bool, |
| 3248 | is_merge: bool, |
| 3249 | ) -> serde_json::Value { |
| 3250 | let mut git = serde_json::json!({ |
| 3251 | "repository": self.options.repo_name, |
| 3252 | "sha": parsed.git_sha, |
| 3253 | "short_sha": parsed.short_sha, |
| 3254 | }); |
| 3255 | |
| 3256 | let diff_files: Vec<serde_json::Value> = parsed |
| 3257 | .files |
| 3258 | .iter() |
| 3259 | .filter_map(|file| { |
| 3260 | file.diff_lines.as_ref().map(|lines| { |
| 3261 | serde_json::json!({ |
| 3262 | "path": file.path, |
| 3263 | "old_path": file.old_path, |
| 3264 | "operation": match file.operation { |
| 3265 | FileOperation::Added => "added", |
| 3266 | FileOperation::Modified => "modified", |
| 3267 | FileOperation::Deleted => "deleted", |
| 3268 | FileOperation::Renamed => "renamed", |
| 3269 | FileOperation::Copied => "copied", |
| 3270 | }, |
| 3271 | "lines": lines, |
| 3272 | }) |
| 3273 | }) |
| 3274 | }) |
| 3275 | .collect(); |
| 3276 | |
| 3277 | if !diff_files.is_empty() { |
| 3278 | git["diff_lines"] = serde_json::Value::Array(diff_files); |
| 3279 | } |
| 3280 | |
| 3281 | if is_empty { |
| 3282 | git["empty_commit"] = serde_json::json!(true); |
| 3283 | } |
| 3284 | if is_merge { |
| 3285 | git["empty_merge"] = serde_json::json!(true); |
| 3286 | } |
| 3287 | |
| 3288 | serde_json::json!({ "git": git }) |
| 3289 | } |
| 3290 | |
| 3291 | // ═══════════════════════════════════════════════════════════════════════ |
| 3292 | // Post-Import Classification |
no test coverage detected