diff --git a/README.md b/README.md index ea139d6..2ea77d4 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,8 @@ keywords: ### Issue Title Transformation You can apply project local issue title transformations. Create -`.snitch.yaml` file in the root of the project with the following -content: +`.snitch.yaml` file in the root of the project or in +`$HOME/.config/snitch/snitch.yaml` with the following content: ```yaml title: diff --git a/project.go b/project.go index e0deb4c..63d9241 100644 --- a/project.go +++ b/project.go @@ -272,6 +272,23 @@ func yamlConfigPath(projectPath string) (string, bool) { } } + var xdgConfig string + if pathToConfig := os.Getenv("XDG_CONFIG_HOME"); pathToConfig != "" { + xdgConfig = pathToConfig + } else { + xdgConfig = path.Join(os.Getenv("HOME"), ".config") + } + + pathToConfig := path.Join(xdgConfig, "snitch/snitch.yaml") + if stat, err := os.Stat(pathToConfig); !os.IsNotExist(err) && !stat.IsDir() { + return pathToConfig, true + } + + pathToConfig = path.Join(xdgConfig, "snitch/snitch.yml") + if stat, err := os.Stat(pathToConfig); !os.IsNotExist(err) && !stat.IsDir() { + return pathToConfig, true + } + return "", false }