fix(lazygit): fix model version and json output parsing

This commit is contained in:
tux
2026-08-07 04:58:11 +05:30
parent 7f43037522
commit 59c9d27342

View File

@@ -87,81 +87,68 @@
title = "AI Generated Commit Messages"; title = "AI Generated Commit Messages";
key = "CommitMsg"; key = "CommitMsg";
command = '' command = ''
bash -c " bash -lc '
# Check for staged changes diff=$(git diff --cached)
diff=\$(git diff --cached | head -n 10) if [ -z "$diff" ]; then
if [ -z \"\$diff\" ]; then echo "No changes in staging. Add changes first."
echo \"No changes in staging. Add changes first.\"
exit 1 exit 1
fi fi
SELECTED_TYPE=\"{{.Form.Type}}\" SELECTED_TYPE="{{.Form.Type}}"
COMMITS_TO_SUGGEST=8 COMMITS_TO_SUGGEST=4
opencode run -m \"google/gemini-2.5-flash-lite\" \" opencode run --format json --model=google/gemini-3.5-flash-lite --variant=none "
You are an expert at writing Git commits. Your job is to write commit messages that follow the Conventional Commits format. You are an expert at writing Git commits. Your job is to write commit messages that follow the Conventional Commits format.
The user has selected: \$SELECTED_TYPE The user has selected: $SELECTED_TYPE
Your task is to: Your task is to:
1. Analyze the code changes 1. Analyze the code changes
2. Determine the most appropriate commit type (if user selected 'ai-defined') 2. Determine the most appropriate commit type if user selected ai-defined
3. Determine an appropriate scope (component/area affected) 3. Determine an appropriate scope, component, or area affected
4. Decide if this is a breaking change 4. Decide if this is a breaking change
5. Write clear, concise commit messages 5. Write clear, concise commit messages
Available commit types: Available commit types:
- feat: A new feature - feat: A new feature
- fix: A bug fix - fix: A bug fix
- docs: Documentation only changes - docs: Documentation only changes
- style: Changes that do not affect the meaning of the code - style: Changes that do not affect the meaning of the code
- refactor: A code change that neither fixes a bug nor adds a feature - refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance - perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests - test: Adding missing tests or correcting existing tests
- build: Changes that affect the build system or external dependencies - build: Changes that affect the build system or external dependencies
- ci: Changes to CI configuration files and scripts - ci: Changes to CI configuration files and scripts
- chore: Other changes that don't modify src or test files - chore: Other changes that do not modify src or test files
- revert: Reverts a previous commit - revert: Reverts a previous commit
Follow these guidelines: Follow these guidelines:
- Structure: <type>(<scope>): <description> - Structure: <type>(<scope>): <description>
- If user selected 'ai-defined', analyze the changes and pick the most suitable type - If user selected ai-defined, analyze the changes and pick the most suitable type
- If user selected a specific type, use that type: \$SELECTED_TYPE - If user selected a specific type, use that type: $SELECTED_TYPE
- Add scope in parentheses if applicable (e.g., auth, api, ui, config) - Add scope in parentheses if applicable, for example auth, api, ui, config
- Use exclamation mark (!) after type/scope for breaking changes: type(scope)!: description - Use exclamation mark after type or scope for breaking changes: type(scope)!: description
- Use lowercase for description (except proper nouns) - Use lowercase for description except proper nouns
- Use imperative mood (\\\"add\\\", not \\\"added\\\") - Use imperative mood: add, not added
- Keep description under 50 characters when possible - Keep description under 50 characters when possible
- No period at the end of subject line - No period at the end of subject line
Examples: IMPORTANT:
- feat(auth): add OAuth login support - Generate exactly $COMMITS_TO_SUGGEST different commit message options
- fix(api): handle null response in user endpoint - If user selected ai-defined, you can use different types for different options
- docs(readme): update installation instructions - If user selected a specific type, all messages must use that type
- style(ui): improve button spacing consistency - Only return commit messages, no explanations
- refactor(database): simplify query builder logic - Do not use markdown code blocks
- test(auth): add unit tests for login flow - One message per line
- build(deps): upgrade React to version 18
- ci(github): fix deployment workflow
- chore(config): update ESLint rules
- perf(api)!: optimize database queries
IMPORTANT: Previous commits for context:
- Generate exactly \$COMMITS_TO_SUGGEST different commit message options $(git log --oneline -10)
- If user selected 'ai-defined', you can use different types for different options
- If user selected a specific type, all messages must use that type
- Only return commit messages, no explanations
- Do not use markdown code blocks
- One message per line
Previous commits for context: Changes to analyze:
\$(git log --oneline -10) $(git diff --cached --stat)
$diff
Changes to analyze: " | JQ_TEXT=text jq -r "select(.type == env.JQ_TEXT) | .part.text? // empty"
\$(git diff --cached --stat) '
\$(git diff --cached)
\"
"
''; '';
} }
]; ];