Extract metadata from a git commit.
(commit: &git2::Commit)
| 4251 | |
| 4252 | /// Extract metadata from a git commit. |
| 4253 | fn extract_commit_metadata(commit: &git2::Commit) -> CliResult<CommitMetadata> { |
| 4254 | let author = commit.author(); |
| 4255 | let author_name = author.name().unwrap_or("Unknown").to_string(); |
| 4256 | let author_email = author.email().map(|s| s.to_string()); |
| 4257 | |
| 4258 | let time = commit.time(); |
| 4259 | let timestamp = Utc |
| 4260 | .timestamp_opt(time.seconds(), 0) |
| 4261 | .single() |
| 4262 | .unwrap_or_else(Utc::now); |
| 4263 | |
| 4264 | let full_message = commit.message().unwrap_or(""); |
| 4265 | let (message, description) = parse_commit_message(full_message); |
| 4266 | |
| 4267 | Ok(CommitMetadata { |
| 4268 | author_name, |
| 4269 | author_email, |
| 4270 | timestamp, |
| 4271 | message, |
| 4272 | description, |
| 4273 | }) |
| 4274 | } |
| 4275 | |
| 4276 | /// Parse files from a git diff. |
| 4277 | /// |
no test coverage detected