Skip to main content

parse_conventional_commit

Function parse_conventional_commit 

Source
pub fn parse_conventional_commit(message: &str) -> Option<ConventionalCommit>
Expand description

Parses a commit message string into a ConventionalCommit.

Recognizes standard types (feat, fix, perf, refactor, chore, docs, style, test, build, ci) and optional scopes. A breaking change is detected if the type/scope header ends with ! or if BREAKING CHANGE: / BREAKING-CHANGE: appears in the commit body or footers.

Returns None if the commit does not adhere to the Conventional Commits specification.

§Arguments

  • message - Full git commit message (subject and optional body/footers).

§Example

use git_claw::core::conventional::parse_conventional_commit;

let commit = parse_conventional_commit("feat(auth)!: add OAuth2 provider").unwrap();
assert_eq!(commit.commit_type, "feat");
assert_eq!(commit.scope, Some("auth".to_string()));
assert!(commit.is_breaking);
assert_eq!(commit.description, "add OAuth2 provider");