Extract metadata from a git commit.
(commit: &git2::Commit)
| 3852 | |
| 3853 | /// Extract metadata from a git commit. |
| 3854 | fn extract_commit_metadata(commit: &git2::Commit) -> CliResult<CommitMetadata> { |
| 3855 | let author = commit.author(); |
| 3856 | let author_name = author.name().unwrap_or("Unknown").to_string(); |
| 3857 | let author_email = author.email().map(|s| s.to_string()); |
| 3858 | |
| 3859 | let time = commit.time(); |
| 3860 | let timestamp = Utc |
| 3861 | .timestamp_opt(time.seconds(), 0) |
| 3862 | .single() |
| 3863 | .unwrap_or_else(Utc::now); |
| 3864 | |
| 3865 | let full_message = commit.message().unwrap_or(""); |
| 3866 | let (message, description) = parse_commit_message(full_message); |
| 3867 | |
| 3868 | Ok(CommitMetadata { |
| 3869 | author_name, |
| 3870 | author_email, |
| 3871 | timestamp, |
| 3872 | message, |
| 3873 | description, |
| 3874 | }) |
| 3875 | } |
| 3876 | |
| 3877 | /// Parse files from a git diff. |
| 3878 | /// |
no test coverage detected