-
Notifications
You must be signed in to change notification settings - Fork 362
Fix defaultIsZeroValue check for generic Value types #422
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
Fix defaultIsZeroValue check for generic Value types #422
Conversation
c6f8d76 to
9edfc8d
Compare
|
Change LGTM, but it'd be nice to have it covered by tests. |
|
I completely agree. However I am quite new to go, and have no experience with writing tests in go 😅. I presume that I should put the test in the existing |
|
Yes, tests for this go in I imagine you should be able to extend this test to ensure your change actually fixes the issue; in other words, with a change to that test but without the feature change in this PR, the test should fail - then applying this PR change again should make the test green again. |
|
I have extended the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry this took a while - been swamped with other things... I have one small nit, but given the delayed response here I'm not going to block on that.
/lgtm
260afbc to
c963093
Compare
|
/lgtm |
|
Thank you for your contribution! |
This PR contains the following updates: | Package | Change | Age | Confidence | |---|---|---|---| | [github.com/spf13/pflag](https://github.com/spf13/pflag) | `v1.0.6` -> `v1.0.7` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>spf13/pflag (github.com/spf13/pflag)</summary> ### [`v1.0.7`](https://github.com/spf13/pflag/releases/tag/v1.0.7) [Compare Source](spf13/pflag@v1.0.6...v1.0.7) #### What's Changed - Fix defaultIsZeroValue check for generic Value types by [@​MidnightRocket](https://github.com/MidnightRocket) in spf13/pflag#422 - feat: Use structs for errors returned by pflag. by [@​eth-p](https://github.com/eth-p) in spf13/pflag#425 - Fix typos by [@​co63oc](https://github.com/co63oc) in spf13/pflag#428 - fix [#​423](spf13/pflag#423) : Add helper function and some documentation to parse shorthand go test flags. by [@​valdar](https://github.com/valdar) in spf13/pflag#424 - add support equivalent to golang flag.TextVar(), also fixes the test failure as described in [#​368](spf13/pflag#368) by [@​hujun-open](https://github.com/hujun-open) in spf13/pflag#418 - add support for Func() and BoolFunc() [#​426](spf13/pflag#426) by [@​LeGEC](https://github.com/LeGEC) in spf13/pflag#429 - fix: correct argument length check in FlagSet.Parse by [@​ShawnJeffersonWang](https://github.com/ShawnJeffersonWang) in spf13/pflag#409 - fix usage message for func flags, fix arguments order by [@​LeGEC](https://github.com/LeGEC) in spf13/pflag#431 - Add support for time.Time flags by [@​max-frank](https://github.com/max-frank) in spf13/pflag#348 #### New Contributors - [@​MidnightRocket](https://github.com/MidnightRocket) made their first contribution in spf13/pflag#422 - [@​eth-p](https://github.com/eth-p) made their first contribution in spf13/pflag#425 - [@​co63oc](https://github.com/co63oc) made their first contribution in spf13/pflag#428 - [@​valdar](https://github.com/valdar) made their first contribution in spf13/pflag#424 - [@​hujun-open](https://github.com/hujun-open) made their first contribution in spf13/pflag#418 - [@​LeGEC](https://github.com/LeGEC) made their first contribution in spf13/pflag#429 - [@​ShawnJeffersonWang](https://github.com/ShawnJeffersonWang) made their first contribution in spf13/pflag#409 - [@​max-frank](https://github.com/max-frank) made their first contribution in spf13/pflag#348 **Full Changelog**: spf13/pflag@v1.0.6...v1.0.7 </details> --- ### Configuration 📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40My41IiwidXBkYXRlZEluVmVyIjoiNDEuNDMuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/794 Reviewed-by: earl-warren <[email protected]> Co-authored-by: Renovate Bot <[email protected]> Co-committed-by: Renovate Bot <[email protected]>
The
defaultIsZeroValuefunction does not check on theDefValuefield, for genericValuetypes., but instead wrongly checks on the flagValuefield.This results in the help screen wrongly displays the default value for a custom Value option, even though the default value is a "zerovalue".
Reproduce
hellocmd --my-option "some-value" -hShould not display the default value in the help screen, but does anyways without this patch.
Example code to reproduce
Similar / related PR
#361
Is related, however solves this problem specifically for
isBoolFlag()=truecustomValuetypes.While this additionally solves for other custom
Valuetypes.