Skip to content

Commit

Permalink
feat: search for config in ${REPO_ROOT}/.config
Browse files Browse the repository at this point in the history
  • Loading branch information
test user committed Aug 1, 2023
1 parent 667e63b commit 50b4e55
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
File renamed without changes.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@ git cc -m "invalid(stuff): should return 1"

### Configuration

See [`./commit_convention.yaml`](./commit_convention.yaml) for an example configuration file.
`git-cc` searches for a configuration file named `commit_convention.{yaml,yml,toml}`.
Note that `git-cc` prefers the extension `yaml` over `yml`, and `yml` over `toml`.


`git-cc` searches the following directories for a configuration file in this order:

```
${PWD}/
${REPO_ROOT}/ # ignored if not inside a git repo
${REPO_ROOT}/.config/ # ignored if not inside a git repo
${XDG_CONFIG_HOME}/
```

See [`./config/commit_convention.yaml`](./.config/commit_convention.yaml) for an example configuration file.

## Why write conventional commits through an interactive CLI?

Expand Down
6 changes: 6 additions & 0 deletions pkg/config/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ func findCCConfigFile(gitRepoRoot string) (string, error) {
}
if gitRepoRoot != "" && gitRepoRoot != cwd {
dirsToSearch = append(dirsToSearch, gitRepoRoot)
dotConfigDir := path.Join(gitRepoRoot, ".config")
if dirInfo, err := os.Stat(dotConfigDir); err == nil {
if dirInfo.IsDir() {
dirsToSearch = append(dirsToSearch, dotConfigDir)
}
}
}
configHome := os.Getenv("XDG_CONFIG_HOME")
if configHome == "" {
Expand Down

0 comments on commit 50b4e55

Please sign in to comment.