Skip to content

Commit 105f2b4

Browse files
feat(app): make commit history depth configurable via max_commit_count (#2762)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent d6d7c04 commit 105f2b4

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

crates/forge_app/src/git_app.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,12 @@ where
231231

232232
/// Fetches git context (branch name and recent commits)
233233
async fn fetch_git_context(&self, cwd: &Path) -> Result<(String, String)> {
234+
let max_commit_count = self.services.get_config().max_commit_count;
235+
let git_log_cmd =
236+
format!("git log --pretty=format:%s --abbrev-commit --max-count={max_commit_count}");
234237
let (recent_commits, branch_name) = tokio::join!(
235-
self.services.execute(
236-
"git log --pretty=format:%s --abbrev-commit --max-count=20".into(),
237-
cwd.to_path_buf(),
238-
false,
239-
true,
240-
None,
241-
None,
242-
),
238+
self.services
239+
.execute(git_log_cmd, cwd.to_path_buf(), false, true, None, None,),
243240
self.services.execute(
244241
"git rev-parse --abbrev-ref HEAD".into(),
245242
cwd.to_path_buf(),

crates/forge_config/.forge.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
auto_open_dump = false
22
max_conversations = 100
3+
max_commit_count = 20
34
max_extensions = 15
45
max_fetch_chars = 50000
56
max_file_read_batch_size = 50

crates/forge_config/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ pub struct ForgeConfig {
108108
/// Model and provider configuration used for commit message generation.
109109
#[serde(default, skip_serializing_if = "Option::is_none")]
110110
pub commit: Option<ModelConfig>,
111+
/// Maximum number of recent commits included as context for commit message
112+
/// generation.
113+
#[serde(default)]
114+
pub max_commit_count: usize,
111115
/// Model and provider configuration used for shell command suggestion
112116
/// generation.
113117
#[serde(default, skip_serializing_if = "Option::is_none")]

forge.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@
6767
}
6868
]
6969
},
70+
"max_commit_count": {
71+
"description": "Maximum number of recent commits included as context for commit message\ngeneration.",
72+
"type": "integer",
73+
"format": "uint",
74+
"default": 0,
75+
"minimum": 0
76+
},
7077
"max_conversations": {
7178
"description": "Maximum number of conversations shown in the conversation list.",
7279
"type": "integer",

0 commit comments

Comments
 (0)