Parse the author string into an Author struct.
(&self)
| 46 | |
| 47 | /// Parse the author string into an Author struct. |
| 48 | pub(crate) fn parse_author(&self) -> Option<Author> { |
| 49 | self.author.as_ref().map(|s| { |
| 50 | // Try to parse "Name <email>" format |
| 51 | if let Some(bracket_start) = s.find('<') { |
| 52 | if let Some(bracket_end) = s.find('>') { |
| 53 | let name = s[..bracket_start].trim(); |
| 54 | let email = s[bracket_start + 1..bracket_end].trim(); |
| 55 | return Author::new(name, Some(email)); |
| 56 | } |
| 57 | } |
| 58 | // Just a name |
| 59 | Author::new(s.trim(), None::<&str>) |
| 60 | }) |
| 61 | } |
| 62 | |
| 63 | /// Get the author from identity store or command-line override. |
| 64 | /// |