Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0583843d90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if cfg.PromptFile != "" { | ||
| promptSource = "user" | ||
| promptFilePath = userPath | ||
| if _, err := loadPromptFile(cfg.PromptFile, promptFilePath, ""); err != nil { | ||
| return cfg, err | ||
| } | ||
| promptFileRepoRoot = "" |
There was a problem hiding this comment.
Validate user prompt_file before higher layers overwrite it
After loading user TOML, this branch only records promptFilePath and defers file loading until the final merged config. If the user config has an invalid prompt_file and a higher-priority layer later sets prompt/promptFile, the invalid file is never validated and Load() now succeeds, silently masking a broken user config that previously produced an error.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05df902903
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err := cmd.Run(); err != nil { | ||
| // Not in a git repo or git not available; no git config to read. | ||
| return gitConfigScopes{}, nil |
There was a problem hiding this comment.
Propagate git config read errors
When git config --list --show-scope exits non-zero, this branch always returns an empty scope set with no error. That hides real failures such as malformed git config files or Git builds that do not support --show-scope, so all ai-commit.* settings are silently dropped and Load() falls back to other layers with incorrect configuration and no actionable signal.
Useful? React with 👍 / 👎.
| if promptFile == "" || baseDir == "" || filepath.IsAbs(promptFile) { | ||
| return promptFile |
There was a problem hiding this comment.
Reject relative promptFile when no base is provided
System scope is passed an empty promptFileBase (intended to disallow relative paths), but this helper returns relative values unchanged when baseDir is empty. Those paths are later resolved from the process working directory, so ai-commit.promptFile in system config becomes CWD-dependent and may fail or load different files depending on where the command is run.
Useful? React with 👍 / 👎.
Closes #17
Summary
Adds
git configas a configuration source alongside the existing TOML files. Users can now set repository-specific behavior (engine, prompt, filters) viagit config --localwithout touching any tracked files — making it practical for third-party repositories.Precedence order (lowest → highest)
~/.config/git-ai-commit/config.toml).git-ai-commit.toml).git/config)Supported git config keys
ai-commit.engineengineai-commit.promptpromptai-commit.promptFileprompt_fileai-commit.maxFileLinesfilter.max_file_linesai-commit.excludePatternsfilter.exclude_patterns(multi-value)ai-commit.defaultExcludePatternsfilter.default_exclude_patterns(multi-value)engines.<name>.argsis not supported — there is no natural mapping for nested TOML tables in git config's flat key-value model.Implementation
internal/config/gitconfig.go— reads allai-commit.*entries in a singlegit config --list --show-scopecall, parses them into per-scope structs, and merges them intoConfig. RelativepromptFilepaths resolve from repo root (local/worktree) or$HOME(global). No path containment restriction applies since.git/configcannot be set by a third-party maintainer via push.internal/config/config.go— updatedLoad()to apply git config scopes at the correct priority positions.Tests
15 unit tests in
internal/config/gitconfig_test.gocovering all fields, multi-value patterns, precedence ordering,promptFilepath resolution, and error cases (prompt exclusivity, invalidmaxFileLines).