Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ $ make && ./_output/$(GOOS)/$(GOARCH)/bin/commitizen init

## Configuration

You can set configuration file that `.czrc` at repository root or home directory. The configuration file that located in repository root have a priority over the one in home directory. The format is the same as the following:
You can set configuration file that `.czrc` at repository root, home directory, or the $XDG_CONFIG_HOME/commitizen directory. The configuration file that located in repository root have a priority over the one in home directory. The format is the same as the following:

```yaml
name: default
Expand Down
13 changes: 13 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,26 @@ func New() *Config {

func (c *Config) initialize() error {
var fpath string
// Check if the configuration file is local to the repo.
if fsutil.IsExists(RCFilename) {
fpath = RCFilename
} else {
// Check if the configuration file is in the user's home directory.
home := sysutil.HomeDir()
p := filepath.Join(home, RCFilename)
if fsutil.IsExists(p) {
fpath = p
} else {
// Check if the configuration file is in the configured
// XDG_CONFIG_HOME directory.
xdgConfigHome, found := os.LookupEnv("XDG_CONFIG_HOME")
if !found {
xdgConfigHome = sysutil.HomeDir()
}
p := filepath.Join(xdgConfigHome, "commitizen", RCFilename)
if fsutil.IsExists(p) {
fpath = p
}
}
}

Expand Down
Loading