Skip to content

Commit 79334cd

Browse files
fix: allow camelcase config overwrites (closes #134)
1 parent 5c34391 commit 79334cd

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

cmd/semantic-release/main.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ func main() {
6565
}
6666
}
6767

68+
func mergeConfigWithDefaults(defaults, conf map[string]string) {
69+
for k, v := range conf {
70+
defaults[k] = v
71+
// case-insensitive overwrite default values
72+
kLower := strings.ToLower(k)
73+
for dk := range defaults {
74+
if strings.ToLower(dk) == kLower && dk != k {
75+
defaults[dk] = v
76+
}
77+
}
78+
}
79+
}
80+
6881
func cliHandler(cmd *cobra.Command, args []string) {
6982
logger := log.New(os.Stderr, "[go-semantic-release]: ", 0)
7083
exitIfError := errorHandler(logger)
@@ -153,9 +166,8 @@ func cliHandler(cmd *cobra.Command, args []string) {
153166
"defaultBranch": repoInfo.DefaultBranch,
154167
"prerelease": fmt.Sprintf("%t", conf.Prerelease),
155168
}
156-
for k, v := range conf.HooksOpts {
157-
hooksConfig[k] = v
158-
}
169+
mergeConfigWithDefaults(hooksConfig, conf.HooksOpts)
170+
159171
exitIfError(hooksExecutor.Init(hooksConfig))
160172

161173
if !conf.NoCI {
@@ -165,9 +177,8 @@ func cliHandler(cmd *cobra.Command, args []string) {
165177
"defaultBranch": repoInfo.DefaultBranch,
166178
"private": fmt.Sprintf("%t", repoInfo.Private),
167179
}
168-
for k, v := range conf.CIConditionOpts {
169-
conditionConfig[k] = v
170-
}
180+
mergeConfigWithDefaults(conditionConfig, conf.CIConditionOpts)
181+
171182
err = ci.RunCondition(conditionConfig)
172183
if err != nil {
173184
herr := hooksExecutor.NoRelease(&hooks.NoReleaseConfig{

0 commit comments

Comments
 (0)