Skip to main content

parse_log

Function parse_log 

Source
pub fn parse_log(input: &str) -> Result<Vec<CommitEntry>>
Available on crate feature parse only.
Expand description

Parse the output of git log --format=<LOG_FORMAT>.

§Errors

Returns Error::ParseError if any record has fewer fields than expected.

§Example

use git_spawn::parse::{parse_log, LOG_FORMAT};
let input = "abc\x1fabc\x1fA\x1fa@x\x1f2024-01-01T00:00:00Z\x1fB\x1fb@y\x1f2024-01-02T00:00:00Z\x1fhi\x1fbody\x1e";
let commits = parse_log(input).unwrap();
assert_eq!(commits.len(), 1);
assert_eq!(commits[0].subject, "hi");
assert_eq!(commits[0].author_name, "A");