From 214ec10f86837c97fd142ac42041325d1b2e71e4 Mon Sep 17 00:00:00 2001 From: adeeshperera Date: Sat, 4 Oct 2025 23:21:26 +0530 Subject: [PATCH] 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) }