Files
git-commit-prefix-gen/examples/custom_config.rs
7000pctAUTO 95f64a2c8f
Some checks failed
CI / test (push) Failing after 2s
Add example files
2026-01-31 11:41:59 +00:00

45 lines
1.4 KiB
Rust

use git_commit_prefix_gen::{Config, CommitConvention};
fn main() {
println!("Git Commit Prefix Generator - Custom Configuration Example");
println!("=========================================================\n");
let custom_config = r#"
type_mapping:
- pattern: "src/**/*.rs" type: "feat"
- pattern: "tests/**/*.rs" type: "test"
- pattern: "docs/**/*.md" type: "docs"
scope_patterns:
- pattern: "^src/([^/]+)/" base: "src"
- pattern: "^lib/([^/]+)/" base: "lib"
ignored_patterns:
- "^target/"
- "^node_modules/"
"#;
println!("Custom config:\n{}", custom_config);
let config: Config = serde_yaml::from_str(custom_config).expect("Failed to parse config");
let convention = config.to_convention();
println!("\nTesting type detection with custom rules:");
let test_files = vec!["src/auth/login.rs", "tests/main.rs", "docs/README.md"];
for file in test_files {
if let Some((commit_type, confidence)) = convention.detect_type(file) {
println!(" {} -> {} (confidence: {:.0}%)", file, commit_type, confidence * 100.0);
} else {
println!(" {} -> No type detected", file);
}
}
println!("\nTesting scope detection:");
let test_scope_files = vec!["src/auth/login.rs", "lib/database/connection.rs"];
for file in test_scope_files {
let scope = convention.detect_scope(file);
println!(" {} -> scope: {:?}", file, scope.map(|s| s.name));
}
}