feat(app): make commit history depth configurable via max_commit_count#2762
Open
tusharmath wants to merge 3 commits intomainfrom
Open
feat(app): make commit history depth configurable via max_commit_count#2762tusharmath wants to merge 3 commits intomainfrom
tusharmath wants to merge 3 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make the number of recent commits included as git context configurable via
max_commit_count, replacing a hardcoded limit of 20.Context
Git context (recent commits + branch name) is fetched and passed to the AI when generating commit messages and performing other git-aware operations. Previously, the commit history was always capped at 20 entries with no way for users to adjust this. In large repositories or workflows where more context improves AI output quality, this limit is too restrictive. Conversely, users in token-sensitive environments may want to reduce it.
Changes
max_commit_countfield toForgeConfigandEnvironmentdomain typesgit_app.rsto readmax_commit_countfrom the environment instead of using a hardcoded2020when unset (preserving existing behavior)forge.schema.jsonto expose the new field in the configuration schemaTestContextto maintain consistent test behaviorKey Implementation Details
The default value of
20is preserved at the infrastructure boundary (forge_infra/src/env.rs), ensuring full backwards compatibility — existing configs withoutmax_commit_countbehave identically to before. Thegit logcommand is dynamically constructed with the configured limit before being executed.Use Cases
Testing
Add the following to your
forge.yaml(orforge.default.yaml) and verify that git context reflects the configured limit:Then trigger a commit message generation or any workflow that reads git context, and confirm only the last 5 commits appear in the context.
To verify the default (no config key set) still works as before, remove the field and confirm behaviour is unchanged.