Extract metadata from a git commit.
(commit: &git2::Commit)
| 3882 | |
| 3883 | /// Extract metadata from a git commit. |
| 3884 | fn extract_commit_metadata(commit: &git2::Commit) -> CliResult<CommitMetadata> { |
| 3885 | let author = commit.author(); |
| 3886 | let author_name = author.name().unwrap_or("Unknown").to_string(); |
| 3887 | let author_email = author.email().map(|s| s.to_string()); |
| 3888 | |
| 3889 | let time = commit.time(); |
| 3890 | let timestamp = Utc |
| 3891 | .timestamp_opt(time.seconds(), 0) |
| 3892 | .single() |
| 3893 | .unwrap_or_else(Utc::now); |
| 3894 | |
| 3895 | let full_message = commit.message().unwrap_or(""); |
| 3896 | let (message, description) = parse_commit_message(full_message); |
| 3897 | |
| 3898 | Ok(CommitMetadata { |
| 3899 | author_name, |
| 3900 | author_email, |
| 3901 | timestamp, |
| 3902 | message, |
| 3903 | description, |
| 3904 | }) |
| 3905 | } |
| 3906 | |
| 3907 | /// Parse files from a git diff. |
| 3908 | /// |
no test coverage detected