parse static method

ConventionalCommit? parse(
  1. String hash,
  2. String subject,
  3. String body
)

Parses a commit, or returns null when its subject does not follow the format.

Implementation

static ConventionalCommit? parse(String hash, String subject, String body) {
  final match = _header.firstMatch(subject.trim());
  if (match == null) {
    return null;
  }
  return ConventionalCommit(
    hash: hash,
    type: match.group(1)!.toLowerCase(),
    scope: match.group(2),
    breaking:
        match.group(3) != null ||
        RegExp(r'^BREAKING[ -]CHANGE:', multiLine: true).hasMatch(body),
    description: match.group(4)!.trim(),
  );
}