Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions crates/forge_app/src/git_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,12 @@ 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(),
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(),
Expand Down
1 change: 1 addition & 0 deletions crates/forge_app/src/orch_spec/orch_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions crates/forge_config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
/// Model and provider configuration used for commit message generation.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub commit: Option<ModelConfig>,
/// 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<usize>,
/// Model and provider configuration used for shell command suggestion
/// generation.
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -162,7 +166,7 @@
}

#[cfg(test)]
mod tests {

Check warning on line 169 in crates/forge_config/src/config.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

items after a test module
use pretty_assertions::assert_eq;

use super::*;
Expand Down
3 changes: 3 additions & 0 deletions crates/forge_domain/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ pub struct Environment {
/// Provider and model for commit message generation.
#[dummy(default)]
pub commit: Option<SessionConfig>,
/// 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<SessionConfig>,
Expand Down
2 changes: 2 additions & 0 deletions crates/forge_infra/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
9 changes: 9 additions & 0 deletions forge.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Loading