go-semantic-release / semantic-release

📦🚀 semantic-release written in Go
https://go-semantic-release.xyz
MIT License
395 stars 43 forks source link

Is mapping ci-condition-opt from the command line wrong? #134

Closed ted-vo closed 2 years ago

ted-vo commented 2 years ago

Hi! My repo setting default branch: develop I just want to use ci-condition-opt to override defaultBranch. My command: ./semantic-release --provider gitlab --ci-condition gitlab --ci-condition-opt defaultBranch="*" --token ***

I see code override ci-condition-opt here: https://github.com/go-semantic-release/semantic-release/blob/5c3439156f8ddb84f0e880b6c29f3a719a0b6ed4/cmd/semantic-release/main.go#L168 image

and pass the conf to condition-gitlab and run condition here: https://github.com/go-semantic-release/condition-gitlab/blob/268fae569178cdfc0b17da5122fa30c7d77f8a03/pkg/condition/gitlab.go#L34 image

Expected behavior: It should be py pass defaultBranch to "*"

Actual behavior: defaultBranch run atcondition-gitlab.RunCondition still is value from repoInfo.DefaultBranch


Try to debug: I just build go-semantic-release by myself to log what it happended

image

Result is in a picture. Value defaultBranch="*" from commend line has been change to defaultbranch:* (key was lowercase). But actual key is defaultBranch pass to RunCondition.

Is it a bug?

p/s: Sorry because English is not my primary language.

christophwitzko commented 2 years ago

Hey @ted-v9n, thanks for investigating this. You are right, passed options are converted to the lowercase representation: https://github.com/go-semantic-release/semantic-release/blob/5c3439156f8ddb84f0e880b6c29f3a719a0b6ed4/pkg/config/config.go#L78 So yes, this is a bug and it is currently impossible to overwrite camelCase configuration options. In your case, you could try the --no-ci flag to skip the ci condition.

ted-vo commented 2 years ago

Hi @christophwitzko , thank you so much. I appiled --no-ci to workaround. 👌

christophwitzko commented 2 years ago

awesome, I also fixed it with the next release 🎉