diff --git a/commit_convention.yaml b/.config/commit_convention.yaml similarity index 100% rename from commit_convention.yaml rename to .config/commit_convention.yaml diff --git a/README.md b/README.md index 8ff98d3..ee6ccec 100644 --- a/README.md +++ b/README.md @@ -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? diff --git a/pkg/config/cfg.go b/pkg/config/cfg.go index eb21f93..f432215 100644 --- a/pkg/config/cfg.go +++ b/pkg/config/cfg.go @@ -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 == "" {