Crates.io | conventional_commits |
lib.rs | conventional_commits |
version | 0.1.1 |
source | src |
created_at | 2024-09-23 22:16:32.420112 |
updated_at | 2024-09-23 22:17:30.164529 |
description | A lightweight parser following the conventional commit standards |
homepage | |
repository | https://github.com/shubhexists/conventional_commits |
max_upload_size | |
id | 1384536 |
size | 21,386 |
A robust Rust library for parsing Conventional Commits, adding human and machine-readable meaning to commit messages.
Add this to your Cargo.toml
:
[dependencies]
conventional-commit = "0.1.0"
Here's a quick example of how to use the Conventional Commits Parser:
use conventional_commit::{parse_commit, Lexer};
fn main() -> Result<(), String> {
let input = "feat(parser): add ability to parse conventional commits".to_string();
let mut lexer = Lexer::new(input);
let tokens = lexer.lex()?;
let commit = parse_commit(tokens)?;
println!("{:?}", commit);
Ok(())
}
A valid Conventional Commit has the following structure:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Type: Describes the kind of change (e.g., feat, fix, docs, style, refactor, test, chore).
feat
, fix
, docs
Scope (optional): Describes what area of the project is changing.
(parser)
, (ui)
, (docs)
Breaking Change Indicator (optional): An exclamation mark (!
) before the colon.
feat!:
or feat(scope)!:
Description: A brief explanation of the change.
add ability to parse conventional commits
Body (optional): Provides additional contextual information about the change.
Footer (optional): Used for referencing issues, noting breaking changes, etc.
:<space>
or <space>#
.BREAKING CHANGE:
, Refs:
, Reviewed-by:
feat(parser): add ability to parse conventional commits
This commit introduces a new parser for Conventional Commits.
The parser can identify commit types, scopes, and descriptions.
Refs: #123
fix!: correct critical bug in authentication flow
BREAKING CHANGE: This changes the API for user authentication.
Old auth tokens will no longer be valid.
docs: update README with new API examples
Updated the README to include examples of how to use
the new parsing functions introduced in v2.0.0.
The following are examples of invalid commits and why they're incorrect:
Missing type:
add new feature
Error: Commit type is missing.
Unclosed scope:
feat(parser: add new parsing logic
Error: Scope is not properly closed with a parenthesis.
Missing description:
feat(ui):
Error: Description is missing.
For detailed API documentation, please refer to the rustdoc comments in the source code.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.