Skip to content

Commit d201d19

Browse files
committed
chore(hooks): update provider model configuration
1 parent 6488d11 commit d201d19

6 files changed

Lines changed: 46 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ git config hooks.prepareCommitMsg true
118118

119119
# For privacy: use local Ollama instead of remote OpenAI
120120
git config hooks.commitProvider ollama
121+
git config hooks.providerModel llama3.2 # Optional: specify model
121122
```
122123

123124
**Step 3: Configure your AI provider:**
@@ -142,6 +143,9 @@ git config hooks.commitTemplate "[JIRA-XXX] feat: message"
142143

143144
# Set language
144145
git config hooks.commitLanguage "es" # Spanish, French, etc.
146+
147+
# Set specific model
148+
git config hooks.providerModel "gpt-4" # or "gpt-3.5-turbo", "llama3.2", etc.
145149
```
146150

147151
## Usage
@@ -201,6 +205,7 @@ git config hooks.prepareCommitMsg true # Auto-generate in editor
201205

202206
# Configure provider
203207
git config hooks.commitProvider ollama # or use OpenAI with OPENAI_API_KEY
208+
git config hooks.providerModel llama3.2 # Optional: specify model
204209
```
205210

206211
Now when you run `git commit`:

hooks/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,29 @@ Both hooks share the same configuration for provider, template, and language:
129129
```bash
130130
# Unix/macOS/Linux
131131
export GIT_COMMIT_PROVIDER="ollama" # or "openai"
132+
export GIT_COMMIT_MODEL="gpt-4" # or "llama3.2"
132133
export GIT_COMMIT_TEMPLATE="[JIRA-XXX] feat: message"
133134
export GIT_COMMIT_LANGUAGE="es"
134135

135136
# Windows
136137
set GIT_COMMIT_PROVIDER=ollama
138+
set GIT_COMMIT_MODEL=gpt-4
137139
set GIT_COMMIT_TEMPLATE=[JIRA-XXX] feat: message
138140
set GIT_COMMIT_LANGUAGE=es
139141
```
140142

141143
**Via Git Config (per repository):**
142144
```bash
143145
git config hooks.commitProvider "ollama" # or "openai"
146+
git config hooks.providerModel "gpt-4" # or "llama3.2", etc
144147
git config hooks.commitTemplate "[JIRA-XXX] feat: message"
145148
git config hooks.commitLanguage "es"
146149
```
147150

148151
**Via Git Config (global):**
149152
```bash
150153
git config --global hooks.commitProvider "openai"
154+
git config --global hooks.providerModel "gpt-4"
151155
git config --global hooks.commitTemplate "feat(scope): message"
152156
git config --global hooks.commitLanguage "en"
153157
```

hooks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# Configuration:
1212
# git config hooks.preCommitPreview true/false # Enable/disable preview
1313
# git config hooks.commitProvider ollama/openai # Set AI provider
14+
# git config hooks.providerModel "gpt-4" # Set model
1415
# git config hooks.commitTemplate "format" # Set template
1516
# git config hooks.commitLanguage "en" # Set language
1617
#
@@ -64,6 +65,12 @@ if ! git diff --cached --quiet; then
6465
set -- npx git-rewrite-commits --staged --provider "$PROVIDER" --skip-remote-consent
6566
fi
6667

68+
# Add model if configured (via environment variable or git config)
69+
MODEL="${GIT_COMMIT_MODEL:-$(git config --get hooks.providerModel)}"
70+
if [ -n "$MODEL" ]; then
71+
set -- "$@" --model "$MODEL"
72+
fi
73+
6774
# Add template if configured (via environment variable or git config)
6875
TEMPLATE="${GIT_COMMIT_TEMPLATE:-$(git config --get hooks.commitTemplate)}"
6976
if [ -n "$TEMPLATE" ]; then

hooks/pre-commit.bat

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ REM git config hooks.preCommitPreview true
88
REM
99
REM Configuration:
1010
REM git config hooks.preCommitPreview true/false - Enable/disable preview
11-
REM git config hooks.commitProvider ollama/openai - Set AI provider
11+
REM git config hooks.commitProvider ollama/openai - Set AI provider
12+
REM git config hooks.providerModel "gpt-4" - Set model
1213
REM git config hooks.commitTemplate "format" - Set template
1314
REM git config hooks.commitLanguage "en" - Set language
1415
REM
@@ -72,6 +73,17 @@ if %ERRORLEVEL% EQU 0 (
7273
set "CMD=git-rewrite-commits --staged --provider %PROVIDER% --skip-remote-consent"
7374
)
7475

76+
REM Add model if configured
77+
set "MODEL="
78+
if defined GIT_COMMIT_MODEL (
79+
set "MODEL=%GIT_COMMIT_MODEL%"
80+
) else (
81+
for /f "tokens=*" %%i in ('git config --get hooks.providerModel 2^>nul') do set "MODEL=%%i"
82+
)
83+
if not "%MODEL%"=="" (
84+
set CMD=%CMD% --model "%MODEL%"
85+
)
86+
7587
REM Add template if configured
7688
set "TEMPLATE="
7789
if defined GIT_COMMIT_TEMPLATE (

hooks/prepare-commit-msg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ if [ -z "$COMMIT_SOURCE" ]; then
108108
set -- npx git-rewrite-commits --staged --provider "$PROVIDER" --skip-remote-consent
109109
fi
110110

111+
# Add model if configured (via environment variable or git config)
112+
MODEL="${GIT_COMMIT_MODEL:-$(git config --get hooks.providerModel)}"
113+
if [ -n "$MODEL" ]; then
114+
set -- "$@" --model "$MODEL"
115+
fi
116+
111117
# Add template if configured (via environment variable or git config)
112118
TEMPLATE="${GIT_COMMIT_TEMPLATE:-$(git config --get hooks.commitTemplate)}"
113119
if [ -n "$TEMPLATE" ]; then

hooks/prepare-commit-msg.bat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ if %ERRORLEVEL% NEQ 0 (
124124
set "CMD=git-rewrite-commits --staged --provider %PROVIDER% --skip-remote-consent"
125125
)
126126

127+
REM Add model if configured
128+
set "MODEL="
129+
if defined GIT_COMMIT_MODEL (
130+
set "MODEL=%GIT_COMMIT_MODEL%"
131+
) else (
132+
for /f "tokens=*" %%i in ('git config --get hooks.providerModel 2^>nul') do set "MODEL=%%i"
133+
)
134+
if not "%MODEL%"=="" (
135+
set CMD=%CMD% --model "%MODEL%"
136+
)
137+
127138
REM Add template if configured
128139
set "TEMPLATE="
129140
if defined GIT_COMMIT_TEMPLATE (

0 commit comments

Comments
 (0)