From 214ec10f86837c97fd142ac42041325d1b2e71e4 Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Sat, 4 Oct 2025 23:21:26 +0530 Subject: [PATCH 1/2] fix #22 : convert LLM provider selection to switch statement - Replaced if-else with switch statement to explicitly handle all providers (gemini, chatgpt, claude, grok) - Used existing commitLLM variable instead of multiple os.Getenv calls --- cmd/commit-msg/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/commit-msg/main.go b/cmd/commit-msg/main.go index fff3c17..f795f48 100644 --- a/cmd/commit-msg/main.go +++ b/cmd/commit-msg/main.go @@ -112,13 +112,16 @@ func main() { } var commitMsg string - if os.Getenv("COMMIT_LLM") == "gemini" { + switch commitLLM { + case "gemini": commitMsg, err = gemini.GenerateCommitMessage(config, changes, apiKey) - } else if os.Getenv("COMMIT_LLM") == "chatgpt" { + case "chatgpt": commitMsg, err = chatgpt.GenerateCommitMessage(config, changes, apiKey) - } else if os.Getenv("COMMIT_LLM") == "claude" { + case "claude": commitMsg, err = claude.GenerateCommitMessage(config, changes, apiKey) - } else { + case "grok": + commitMsg, err = grok.GenerateCommitMessage(config, changes, apiKey) + default: commitMsg, err = grok.GenerateCommitMessage(config, changes, apiKey) } From 114d4a175c0a9b16e17ce9a2351763a345d20b9e Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Sun, 5 Oct 2025 00:04:33 +0530 Subject: [PATCH 2/2] refactor: remove explicit Grok case from LLM provider switch Removed the explicit Grok case, keeping Grok as the default fallback provider --- cmd/commit-msg/main.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmd/commit-msg/main.go b/cmd/commit-msg/main.go index f795f48..7689d28 100644 --- a/cmd/commit-msg/main.go +++ b/cmd/commit-msg/main.go @@ -118,9 +118,7 @@ func main() { case "chatgpt": commitMsg, err = chatgpt.GenerateCommitMessage(config, changes, apiKey) case "claude": - commitMsg, err = claude.GenerateCommitMessage(config, changes, apiKey) - case "grok": - commitMsg, err = grok.GenerateCommitMessage(config, changes, apiKey) + commitMsg, err = claude.GenerateCommitMessage(config, changes, apiKey) default: commitMsg, err = grok.GenerateCommitMessage(config, changes, apiKey) }