Extract metadata from a git commit.
(commit: &git2::Commit)
| 3734 | |
| 3735 | /// Extract metadata from a git commit. |
| 3736 | fn extract_commit_metadata(commit: &git2::Commit) -> CliResult<CommitMetadata> { |
| 3737 | let author = commit.author(); |
| 3738 | let author_name = author.name().unwrap_or("Unknown").to_string(); |
| 3739 | let author_email = author.email().map(|s| s.to_string()); |
| 3740 | |
| 3741 | let time = commit.time(); |
| 3742 | let timestamp = Utc |
| 3743 | .timestamp_opt(time.seconds(), 0) |
| 3744 | .single() |
| 3745 | .unwrap_or_else(Utc::now); |
| 3746 | |
| 3747 | let full_message = commit.message().unwrap_or(""); |
| 3748 | let (message, description) = parse_commit_message(full_message); |
| 3749 | |
| 3750 | Ok(CommitMetadata { |
| 3751 | author_name, |
| 3752 | author_email, |
| 3753 | timestamp, |
| 3754 | message, |
| 3755 | description, |
| 3756 | }) |
| 3757 | } |
| 3758 | |
| 3759 | /// Parse files from a git diff. |
| 3760 | /// |
no test coverage detected