-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/pre commit #449
base: master
Are you sure you want to change the base?
Feat/pre commit #449
Conversation
…ation in cache dir
…and performance The commit introduces new configuration options for logging and caching in OpenCommit. Users can now enable/disable logging and caching, and customize the directories for storing logs and cache files. This improves debugging capabilities, performance optimization, and pre-commit hook integration. The changes include updates to the README.md documentation, configuration handling in config.ts, and enhancements to the commit cache and logger utilities.
@majiayu000 hi, thank you for the contribution. could you describe in few words how it works pls? there is also a broken test |
execSync(` | ||
mkdir -p "${TEST_REPO}" | ||
cd "${TEST_REPO}" | ||
git init | ||
git config user.name "test" | ||
git config user.email "test@test.com" | ||
echo "test" > test.txt | ||
git add test.txt | ||
`); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium test
absolute path
execSync(` | ||
mkdir -p "${TEST_REPO2}" | ||
cd "${TEST_REPO2}" | ||
git init | ||
git config user.name "test" | ||
git config user.email "test@test.com" | ||
echo "test2" > test2.txt | ||
git add test2.txt | ||
`); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium test
absolute path
Hi, sorry for my recklessness. The caching system is designed to store and reuse commit messages, improving commit efficiency and reducing AI API calls. The system preserves recent commit messages and offers reuse options when committing the same files again. Cache functionality can be customized through the following configuration options: # Enable/disable caching (default: true)
OCO_ENABLE_CACHE=true
# Custom cache directory path (default: ~/.cache/opencommit/)
OCO_CACHE_DIR=/path/to/custom/cache Core Features1. Cache Storage
2. Cache LookupBefore generating a new commit message, the system will:
3. Cache CleanupThe system implements two cache cleanup mechanisms: Immediate Cleanup
Periodic Cleanup
WorkflowUnable to render rich display Could not find a suitable point for the given distance graph TD
A[Start Commit] --> B{Check Cache}
B -->|Cache Match Found| C{Ask User}
B -->|No Match| D[Generate New Message]
C -->|Accept| E[Use Cached Message]
C -->|Decline| D
D --> F[Save to Cache]
E --> G[Execute Commit]
F --> G
G --> H[Clear Current Cache]
H --> I[End]
Implementation DetailsCache Directory Structure
Cache File Example{
"message": "feat: implement user authentication",
"timestamp": 1709123456789,
"files": [
"src/auth/login.ts",
"src/auth/middleware.ts"
],
"repoPath": "/path/to/repository"
} |
- Simplify commit message and output display using a consistent separator - Remove duplicate logging and reduce verbosity in commit and cache processes - Enhance test setup for commit cache by explicitly enabling cache
About the failed test, it was caused by environment variables. When OCO_ENABLE_CACHE is false, the test fails. Now I have fixed the bug in test. It use |
Hi!
I've added a commit message caching feature.
I implemented this because my pre-commit checks frequently failed, and yesterday I consumed 40k tokens for a single commit attempt.
For the caching system, I followed the XDG specification and stored the cache in the ~/.cache directory.