Skip to content

Commit 0bf5c92

Browse files
committed
feat: make scope and commit type inference public
Exposing `infer_commit_type` and `infer_scope` as public functions allows external services to use these utilities for commit message generation, improving flexibility and reusability in the codebase.
1 parent c145adf commit 0bf5c92

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/services/context.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ impl ContextBuilder {
3232
config: &Config,
3333
) -> PromptContext {
3434
let commit_type = Self::infer_commit_type(changes, symbols);
35-
let scope = Self::infer_scope(changes);
35+
let scope = if config.format.include_scope {
36+
Self::infer_scope(changes)
37+
} else {
38+
None
39+
};
3640

3741
// Build components with budget management
3842
let change_summary = Self::summarize_changes(changes);
@@ -69,7 +73,7 @@ impl ContextBuilder {
6973
}
7074
}
7175

72-
fn infer_commit_type(changes: &StagedChanges, symbols: &[CodeSymbol]) -> CommitType {
76+
pub fn infer_commit_type(changes: &StagedChanges, symbols: &[CodeSymbol]) -> CommitType {
7377
let categories: Vec<_> = changes.files.iter().map(|f| f.category).collect();
7478

7579
// All docs -> docs
@@ -130,7 +134,7 @@ impl ContextBuilder {
130134
CommitType::Feat
131135
}
132136

133-
fn infer_scope(changes: &StagedChanges) -> Option<String> {
137+
pub fn infer_scope(changes: &StagedChanges) -> Option<String> {
134138
let scopes: Vec<_> = changes
135139
.files
136140
.iter()

0 commit comments

Comments
 (0)