Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow local configs #119

Merged
merged 1 commit into from
Feb 9, 2023
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
19 changes: 19 additions & 0 deletions .changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
check_for_updates: false
excluded_labels:
- maintenance
- dependencies
file_name: CHANGELOG.md
logger: spinner
no_color: false
sections:
added:
- feature
- enhancement
changed:
- backwards-incompatible
fixed:
- bug
- bugfix
- documentation
show_unreleased: true
skip_entries_without_label: false
10 changes: 6 additions & 4 deletions internal/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,20 @@ func (c *configuration) PrintYAML(noColor bool, writer io.Writer) error {
func InitConfig() error {
home, _ := os.UserHomeDir()

viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.SetConfigName(".changelog")
viper.SetConfigType("yml")

cfgPath := filepath.Join(home, ".config", "gh-changelog")
viper.AddConfigPath(cfgPath)

if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
if err := os.MkdirAll(cfgPath, 0750); err != nil {
return fmt.Errorf("failed to create config directory: %s", err)
}
}

// Viper search paths in order of precedence
viper.AddConfigPath(".")
viper.AddConfigPath(cfgPath)

setDefaults()

if err := viper.ReadInConfig(); err != nil {
Expand Down