pub struct Commit {
pub title: String,
pub description: String,
}
Fieldsยง
ยงtitle: String
The title of the commit.
description: String
An exhaustive description of the changes.
Implementationsยง
Sourceยงimpl Commit
impl Commit
Sourcepub fn new(title: String, description: String) -> Self
pub fn new(title: String, description: String) -> Self
Examples found in repository?
examples/basic_usage.rs (lines 12-15)
10fn main() {
11 // Example of creating a commit struct
12 let commit = Commit::new(
13 "feat: add basic usage example".to_string(),
14 "This example demonstrates how to use noob-commit programmatically and shows the basic structure of commit messages.".to_string(),
15 );
16
17 println!("Example commit title: {}", commit.title);
18 println!("Example commit description: {}", commit.description);
19 println!("\nFull commit message:\n{}", commit.to_string());
20
21 // Example of checking for API key
22 match env::var("OPENAI_API_KEY") {
23 Ok(_) => println!("โ
OpenAI API key is set"),
24 Err(_) => println!("โ OpenAI API key is not set. Set OPENAI_API_KEY environment variable"),
25 }
26
27 println!("\nTo use noob-commit:");
28 println!("1. Stage your changes: git add .");
29 println!("2. Run: noob-commit");
30 println!("3. Or for dry run: noob-commit --dry-run");
31 println!("4. To review before commit: noob-commit --review");
32}
More examples
examples/mock_commit.rs (lines 13-16)
10fn main() {
11 // Example commit messages for different scenarios
12 let commit_examples = vec![
13 Commit::new(
14 "feat: add user authentication system".to_string(),
15 "Implemented OAuth2 authentication with support for Google and GitHub providers. Added JWT token generation and validation for secure session management.".to_string(),
16 ),
17 Commit::new(
18 "fix: resolve memory leak in cache handler".to_string(),
19 "Fixed memory leak caused by unreleased references in the LRU cache implementation. Added proper cleanup in the destructor and improved memory management.".to_string(),
20 ),
21 Commit::new(
22 "docs: update API documentation with new endpoints".to_string(),
23 "Added comprehensive documentation for the new REST API endpoints including request/response examples, authentication requirements, and error codes.".to_string(),
24 ),
25 Commit::new(
26 "refactor: improve error handling in database module".to_string(),
27 "Refactored database error handling to use Result types consistently. Added custom error types for better error propagation and debugging.".to_string(),
28 ),
29 Commit::new(
30 "test: add unit tests for payment processing".to_string(),
31 "Added comprehensive unit tests for payment processing module covering edge cases, error scenarios, and successful payment flows.".to_string(),
32 ),
33 ];
34
35 println!("Example commit messages:");
36 println!("========================");
37
38 for (i, commit) in commit_examples.iter().enumerate() {
39 println!("\n{}. Title: {}", i + 1, commit.title);
40 println!(" Description: {}", commit.description);
41 }
42
43 println!("\nThese are examples of well-formatted commit messages that follow conventional commit standards.");
44 println!("When using noob-commit, the AI will generate similar messages based on your staged changes.");
45}
Trait Implementationsยง
Sourceยงimpl<'de> Deserialize<'de> for Commit
impl<'de> Deserialize<'de> for Commit
Sourceยงfn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Sourceยงimpl JsonSchema for Commit
impl JsonSchema for Commit
Sourceยงfn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Sourceยงfn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Sourceยงfn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref
keyword. Read moreSourceยงfn always_inline_schema() -> bool
fn always_inline_schema() -> bool
๐Deprecated: Use
inline_schema()
insteadOnly included for backward-compatibility - use
inline_schema()
insteadโ. Read moreAuto Trait Implementationsยง
impl Freeze for Commit
impl RefUnwindSafe for Commit
impl Send for Commit
impl Sync for Commit
impl Unpin for Commit
impl UnwindSafe for Commit
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more