Skip to main content

commit_example/
commit_example.rs

1use chrono::DateTime;
2use semver_common::Commit;
3
4fn main() {
5    let c = String::from(
6        "490049bf36b19b30d23b4be5a4u94f71b5c6475c
7    Author: Some Author <myemail@email.com>
8    Date:   Tue Apr 14 17:35:15 2026 -0400
9    
10        feat: added feature to get commit list
11    ",
12    );
13    let commit = Commit::new_from_commit(c).expect("Commit could not be instantiated during test.");
14    assert_eq!(commit.id(), "490049bf36b19b30d23b4be5a4u94f71b5c6475c");
15    assert_eq!(commit.author(), "Some Author <myemail@email.com>");
16    assert_eq!(
17        commit.timestamp(),
18        &DateTime::parse_from_str("Tue Apr 14 17:35:15 2026 -0400", "%a %b %d %H:%M:%S %Y %z")
19            .unwrap()
20    );
21    assert_eq!(commit.message(), "feat: added feature to get commit list");
22}