-
Notifications
You must be signed in to change notification settings - Fork 220
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
src: Update dependencies and fix issue with usage message #917
Conversation
Build failed.
|
recheck |
Build failed.
|
Umm... I don't quite understand much from the commit messages. Is there an actual regression in Cobra that we are addressing? But since we haven't updated the dependencies, how can it be a recent regression? Or are these just a periodic update of the dependencies? |
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.
It will be easier to understand if the commit message included a clear example of the change in behaviour of Cobra. Like in spf13/cobra#1532
Ah, I see that it's a change in behaviour in newer Cobra versions that distributors might be using for their builds! In that case, does the newer approach of using the templates also work with older versions of Cobra? I am asking because different versions of Fedora might have different versions of Cobra. |
The template has been available from the very first version of Cobra, so yes. |
6af7c77
to
5ee1518
Compare
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1 - github.com/fsnotify/fsnotify v1.4.7 => v1.4.9 - github.com/godbus/dbus/v5 v5.0.3 => v5.0.6 - github.com/konsorten/go-windows-terminal-sequences v1.0.1 => v1.0.3 - github.com/magiconair/properties v1.8.0 => v1.8.5 - github.com/mattn/go-colorable v0.1.2 => v0.1.11 - github.com/mattn/go-isatty v0.0.8 => v0.0.14 - github.com/spf13/cast v1.3.0 => v1.3.1 - github.com/spf13/cobra v0.0.5 => v0.0.7 - github.com/spf13/pflag v1.0.3 => v1.0.5 - github.com/spf13/viper v1.3.2 => v1.4.0 - golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211115234514-b4de73f9ece8 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211113001501-0c823b97ae02 - golang.org/x/text v0.3.0 => v0.3.7 - gopkg.in/yaml.v2 v2.2.2 => v2.2.8 containers#917
- github.com/briandowns/spinner v1.10.0 => v1.16.0 - github.com/fatih/color v1.7.0 => v1.13.0 - github.com/fsnotify/fsnotify v1.4.9 => v1.5.1 - github.com/sirupsen/logrus v1.4.2 => v1.8.1 - github.com/spf13/cast v1.3.1 => v1.4.1 - github.com/spf13/cobra v0.0.7 => v1.2.1 - github.com/spf13/viper v1.4.0 => v1.9.0 - gopkg.in/ini.v1 v1.63.2 => v1.64.0 - gopkg.in/yaml.v2 v2.2.8 => v2.4.0 containers#917
In version 1.1.2 of Cobra has been included a change[0] that changes the behaviour of how custom usage functions are printed. The change prepends "Error: " to the text. This is not desired since the usage text is not an error text. Example of the wrong behaviour: $ toolbox --foo Error: unknown flag: --foo Error: Run 'toolbox --help' for usage. Desired behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. Because the template is set only once, the executableBase needs to be set before the template is applied. That required the move of setUpGlobals() into init() of the cmd package. This is a better place for the function call as init() is called earlier than Execute()[3]. Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 [3] https://golang.org/doc/effective_go#init containers#917
5ee1518
to
8bcb56a
Compare
Build failed.
|
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1 - github.com/fsnotify/fsnotify v1.4.7 => v1.4.9 - github.com/godbus/dbus/v5 v5.0.3 => v5.0.6 - github.com/konsorten/go-windows-terminal-sequences v1.0.1 => v1.0.3 - github.com/magiconair/properties v1.8.0 => v1.8.5 - github.com/mattn/go-colorable v0.1.2 => v0.1.11 - github.com/mattn/go-isatty v0.0.8 => v0.0.14 - github.com/spf13/cast v1.3.0 => v1.3.1 - github.com/spf13/cobra v0.0.5 => v0.0.7 - github.com/spf13/pflag v1.0.3 => v1.0.5 - github.com/spf13/viper v1.3.2 => v1.4.0 - golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211115234514-b4de73f9ece8 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211113001501-0c823b97ae02 - golang.org/x/text v0.3.0 => v0.3.7 - gopkg.in/yaml.v2 v2.2.2 => v2.2.8 containers#917
- github.com/briandowns/spinner v1.10.0 => v1.16.0 - github.com/fatih/color v1.7.0 => v1.13.0 - github.com/fsnotify/fsnotify v1.4.9 => v1.5.1 - github.com/sirupsen/logrus v1.4.2 => v1.8.1 - github.com/spf13/cast v1.3.1 => v1.4.1 - github.com/spf13/cobra v0.0.7 => v1.2.1 - github.com/spf13/viper v1.4.0 => v1.9.0 - gopkg.in/ini.v1 v1.63.2 => v1.64.0 - gopkg.in/yaml.v2 v2.2.8 => v2.4.0 containers#917
In version 1.1.2 of Cobra has been included a change[0] that changes the behaviour of how custom usage functions are printed. The change prepends "Error: " to the text. This is not desired since the usage text is not an error text. Example of the wrong behaviour: $ toolbox --foo Error: unknown flag: --foo Error: Run 'toolbox --help' for usage. Desired behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. Because the template is set only once, the executableBase needs to be set before the template is applied. That required the move of setUpGlobals() into init() of the cmd package. This is a better place for the function call as init() is called earlier than Execute()[3]. Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 [3] https://golang.org/doc/effective_go#init containers#917
This supersedes #775 |
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1 - github.com/fsnotify/fsnotify v1.4.7 => v1.4.9 - github.com/godbus/dbus/v5 v5.0.3 => v5.0.6 - github.com/konsorten/go-windows-terminal-sequences v1.0.1 => v1.0.3 - github.com/magiconair/properties v1.8.0 => v1.8.5 - github.com/mattn/go-colorable v0.1.2 => v0.1.11 - github.com/mattn/go-isatty v0.0.8 => v0.0.14 - github.com/spf13/cast v1.3.0 => v1.3.1 - github.com/spf13/cobra v0.0.5 => v0.0.7 - github.com/spf13/pflag v1.0.3 => v1.0.5 - github.com/spf13/viper v1.3.2 => v1.4.0 - golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211115234514-b4de73f9ece8 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211113001501-0c823b97ae02 - golang.org/x/text v0.3.0 => v0.3.7 - gopkg.in/yaml.v2 v2.2.2 => v2.2.8 containers#917
- github.com/briandowns/spinner v1.10.0 => v1.16.0 - github.com/fatih/color v1.7.0 => v1.13.0 - github.com/fsnotify/fsnotify v1.4.9 => v1.5.1 - github.com/sirupsen/logrus v1.4.2 => v1.8.1 - github.com/spf13/cast v1.3.1 => v1.4.1 - github.com/spf13/cobra v0.0.7 => v1.2.1 - github.com/spf13/viper v1.4.0 => v1.9.0 - gopkg.in/ini.v1 v1.63.2 => v1.64.0 - gopkg.in/yaml.v2 v2.2.8 => v2.4.0 containers#917
In version 1.1.2 of Cobra has been included a change[0] that changes the behaviour of how custom usage functions are printed. The change prepends "Error: " to the text. This is not desired since the usage text is not an error text. Example of the wrong behaviour: $ toolbox --foo Error: unknown flag: --foo Error: Run 'toolbox --help' for usage. Desired behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. Because the template is set only once, the executableBase needs to be set before the template is applied. That required the move of setUpGlobals() into init() of the cmd package. This is a better place for the function call as init() is called earlier than Execute()[3]. Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 [3] https://golang.org/doc/effective_go#init containers#917
8bcb56a
to
a1691f4
Compare
Build failed.
|
In version 1.1.2 of Cobra has been included a change[0] that changes the behaviour of how custom usage functions are printed. The change prepends "Error: " to the text. This is not desired since the usage text is not an error text. Example of the wrong behaviour: $ toolbox --foo Error: unknown flag: --foo Error: Run 'toolbox --help' for usage. Desired behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. Because the template is set only once, the executableBase needs to be set before the template is applied. That required the move of setUpGlobals() into init() of the cmd package. This is a better place for the function call as init() is called earlier than Execute()[3]. Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 [3] https://golang.org/doc/effective_go#init containers#917
a1691f4
to
8c00233
Compare
Build failed.
|
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.
Thanks. One quick comment:
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1 - github.com/fsnotify/fsnotify v1.4.7 => v1.4.9 - github.com/godbus/dbus/v5 v5.0.3 => v5.0.6 - github.com/mattn/go-isatty v0.0.8 => v0.0.14 - github.com/spf13/cobra v0.0.5 => v0.0.7 - github.com/spf13/viper v1.3.2 => v1.4.0 - golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211115234514-b4de73f9ece8 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211113001501-0c823b97ae02 containers#917
Some more observations ... As far as I understand, the wrong behaviour isn't this, as mentioned in the commit message:
It's actually this:
ie., the usage string gets strangely duplicated, with an We could have avoided the duplication by not printing the text ourselves, if it wasn't for the extra prefix, etc.. These are details that we don't have to explain in detail, but the example is important. A wrong example will confuse people even more because it won't match their observation. Secondly, we should bump the dependencies with |
github.com/mattn/go-isatty v0.0.8 | ||
github.com/fsnotify/fsnotify v1.4.9 | ||
github.com/godbus/dbus/v5 v5.0.6 | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect |
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.
We don't need to highlight the changes in the indirect dependencies in the commit message. There are just too many of those and they keep coming and going. It's better to only highlight our direct dependencies in the commit message, unless there's one that we really need to be careful about.
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.
Fair enough.
In version 1.1.2 of Cobra has been included a change[0] that changes how custom usage functions are handled. Example of the wrong behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage.Error: Run 'toolbox --help' for usage. Desired behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. Because the template is set only once, the executableBase needs to be set before the template is applied. That required the move of setUpGlobals() into init() of the cmd package. This is a better place for the function call as init() is called earlier than Execute()[3]. Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 [3] https://golang.org/doc/effective_go#init containers#917
- github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 => v0.1.0 - github.com/briandowns/spinner v1.10.0 => v1.17.0 - github.com/fsnotify/fsnotify v1.4.9 => v1.5.1 - github.com/sirupsen/logrus v1.4.2 => v1.8.1 - github.com/spf13/cobra v0.0.7 => v1.3.0 - github.com/spf13/viper v1.4.0 => v1.10.1 - golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 => v0.0.0-20211215153901-e495a2d5b3d3 - golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 => v0.0.0-20211216021012-1d35b9e2eb4e containers#917
8c00233
to
73c53a3
Compare
Build failed.
|
recheck |
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1 - github.com/fsnotify/fsnotify v1.4.7 => v1.4.9 - github.com/godbus/dbus/v5 v5.0.3 => v5.0.6 - github.com/mattn/go-isatty v0.0.8 => v0.0.14 - github.com/spf13/cobra v0.0.5 => v0.0.7 - github.com/spf13/viper v1.3.2 => v1.4.0 - golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211215153901-e495a2d5b3d3 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211216021012-1d35b9e2eb4e containers#917
In version 1.1.2 of Cobra has been included a change[0] that changes how custom usage functions are handled. Example of the wrong behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage.Error: Run 'toolbox --help' for usage. Desired behaviour: $ toolbox --foo Error: unknown flag: --foo Run 'toolbox --help' for usage. A workaround is to define a template string for the usage instead. The template uses the templating language of Go[1]. See the default template string in version 1.2.1[2]. Because the template is set only once, the executableBase needs to be set before the template is applied. That required the move of setUpGlobals() into init() of the cmd package. This is a better place for the function call as init() is called earlier than Execute()[3]. Upstream issue: spf13/cobra#1532 [0] spf13/cobra#1044 [1] https://pkg.go.dev/text/template [2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 [3] https://golang.org/doc/effective_go#init containers#917
- github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 => v0.1.0 - github.com/briandowns/spinner v1.10.0 => v1.17.0 - github.com/fsnotify/fsnotify v1.4.9 => v1.5.1 - github.com/sirupsen/logrus v1.4.2 => v1.8.1 - github.com/spf13/cobra v0.0.7 => v1.3.0 - github.com/spf13/viper v1.4.0 => v1.10.1 - golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 => v0.0.0-20211215153901-e495a2d5b3d3 - golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 => v0.0.0-20211216021012-1d35b9e2eb4e containers#917
73c53a3
to
979e6d8
Compare
Wow! Software Factory is really struggling today. |
Build failed.
|
979e6d8
to
73c53a3
Compare
We haven't updated the dependencies of Toolbox since the rewrite in Go. There was no real need since our main target is Fedora that takes care of updating the different packages. But because of that we did not catch a regressions in Cobra (see the commit messages).
The dependency update has been done first for patch versions and then even for major versions. Both steps were filled with a call to
go mod tidy
.Fixes #962