From 71e227f951561697efd4aeeaf3de2c3a2c0215ad Mon Sep 17 00:00:00 2001 From: Tushar Date: Wed, 1 Apr 2026 13:45:01 +0530 Subject: [PATCH 1/2] feat(app): add max_commit_count support for git context fetch --- crates/forge_app/src/git_app.rs | 6 +++++- crates/forge_app/src/orch_spec/orch_setup.rs | 1 + crates/forge_config/src/config.rs | 4 ++++ crates/forge_domain/src/env.rs | 3 +++ crates/forge_infra/src/env.rs | 2 ++ forge.schema.json | 9 +++++++++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/forge_app/src/git_app.rs b/crates/forge_app/src/git_app.rs index 8751d913ca..bfc102a35c 100644 --- a/crates/forge_app/src/git_app.rs +++ b/crates/forge_app/src/git_app.rs @@ -224,9 +224,13 @@ where /// Fetches git context (branch name and recent commits) async fn fetch_git_context(&self, cwd: &Path) -> Result<(String, String)> { + let max_commit_count = self.services.get_environment().max_commit_count; + let git_log_cmd = format!( + "git log --pretty=format:%s --abbrev-commit --max-count={max_commit_count}" + ); let (recent_commits, branch_name) = tokio::join!( self.services.execute( - "git log --pretty=format:%s --abbrev-commit --max-count=20".into(), + git_log_cmd, cwd.to_path_buf(), false, true, diff --git a/crates/forge_app/src/orch_spec/orch_setup.rs b/crates/forge_app/src/orch_spec/orch_setup.rs index f03ff78aca..1a1ddbcae0 100644 --- a/crates/forge_app/src/orch_spec/orch_setup.rs +++ b/crates/forge_app/src/orch_spec/orch_setup.rs @@ -96,6 +96,7 @@ impl Default for TestContext { model_cache_ttl: 604_800, session: None, commit: None, + max_commit_count: 20, suggest: None, is_restricted: false, temperature: None, diff --git a/crates/forge_config/src/config.rs b/crates/forge_config/src/config.rs index 366633054e..189bfe11e1 100644 --- a/crates/forge_config/src/config.rs +++ b/crates/forge_config/src/config.rs @@ -106,6 +106,10 @@ pub struct ForgeConfig { /// Model and provider configuration used for commit message generation. #[serde(default, skip_serializing_if = "Option::is_none")] pub commit: Option, + /// Maximum number of recent commits included as context for commit message + /// generation. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub max_commit_count: Option, /// Model and provider configuration used for shell command suggestion /// generation. #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/crates/forge_domain/src/env.rs b/crates/forge_domain/src/env.rs index 1db2b2903c..ea332a26eb 100644 --- a/crates/forge_domain/src/env.rs +++ b/crates/forge_domain/src/env.rs @@ -141,6 +141,9 @@ pub struct Environment { /// Provider and model for commit message generation. #[dummy(default)] pub commit: Option, + /// Maximum number of recent commits to include as context during commit + /// message generation. + pub max_commit_count: usize, /// Provider and model for shell command suggestion generation. #[dummy(default)] pub suggest: Option, diff --git a/crates/forge_infra/src/env.rs b/crates/forge_infra/src/env.rs index aeb5882838..6feb359979 100644 --- a/crates/forge_infra/src/env.rs +++ b/crates/forge_infra/src/env.rs @@ -165,6 +165,7 @@ fn to_environment(fc: ForgeConfig, cwd: PathBuf) -> Environment { model_cache_ttl: fc.model_cache_ttl_secs.unwrap_or_default(), session: fc.session.as_ref().map(to_session_config), commit: fc.commit.as_ref().map(to_session_config), + max_commit_count: fc.max_commit_count.unwrap_or(20), suggest: fc.suggest.as_ref().map(to_session_config), is_restricted: fc.restricted.unwrap_or_default(), tool_supported: fc.tool_supported.unwrap_or_default(), @@ -349,6 +350,7 @@ fn to_forge_config(env: &Environment) -> ForgeConfig { provider_id: sc.provider_id.clone(), model_id: sc.model_id.clone(), }); + fc.max_commit_count = Some(env.max_commit_count); fc.suggest = env.suggest.as_ref().map(|sc| ModelConfig { provider_id: sc.provider_id.clone(), model_id: sc.model_id.clone(), diff --git a/forge.schema.json b/forge.schema.json index b529d71e07..8c55d587f6 100644 --- a/forge.schema.json +++ b/forge.schema.json @@ -69,6 +69,15 @@ } ] }, + "max_commit_count": { + "description": "Maximum number of recent commits included as context for commit message\ngeneration.", + "type": [ + "integer", + "null" + ], + "format": "uint", + "minimum": 0 + }, "max_conversations": { "description": "Maximum number of conversations shown in the conversation list.", "type": [ From 1cfa237f2101e0e8bfae70be1a13f7df39b28ed1 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 08:16:58 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- crates/forge_app/src/git_app.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/forge_app/src/git_app.rs b/crates/forge_app/src/git_app.rs index bfc102a35c..9bf871f7a4 100644 --- a/crates/forge_app/src/git_app.rs +++ b/crates/forge_app/src/git_app.rs @@ -225,18 +225,11 @@ where /// Fetches git context (branch name and recent commits) async fn fetch_git_context(&self, cwd: &Path) -> Result<(String, String)> { let max_commit_count = self.services.get_environment().max_commit_count; - let git_log_cmd = format!( - "git log --pretty=format:%s --abbrev-commit --max-count={max_commit_count}" - ); + let git_log_cmd = + format!("git log --pretty=format:%s --abbrev-commit --max-count={max_commit_count}"); let (recent_commits, branch_name) = tokio::join!( - self.services.execute( - git_log_cmd, - cwd.to_path_buf(), - false, - true, - None, - None, - ), + self.services + .execute(git_log_cmd, cwd.to_path_buf(), false, true, None, None,), self.services.execute( "git rev-parse --abbrev-ref HEAD".into(), cwd.to_path_buf(),