-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Remove .exe
suffix if any in completion
#24966
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: silver886 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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 for the fix, please add the description from the PR also to the commit message.
It would also be a good idea to have some form of test, I think podman --help
might be enough to run on windows and check the Usage string?
@l0rd Any idea where this could be added?
@@ -62,7 +62,7 @@ Options: | |||
|
|||
var ( | |||
rootCmd = &cobra.Command{ | |||
Use: filepath.Base(os.Args[0]) + " [options]", | |||
Use: strings.TrimSuffix(filepath.Base(os.Args[0]), ".exe") + " [options]", |
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.
Can you add a comment here why .exe is trimmed and add a link to the issue.
If the line is moved or edited again it may no longer be easy to find in the git history.
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.
Comment and links to issue and pr are added.
I also added description to the commit message.
LGTM other than the comment |
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 please also squash the commits as this is one change.
@Luap99 do you mean something similar to I have manually tested this PR, and completion works fine on Powershell for podman, with and without One minor comment:
I may be missing something but it looks like the cobra issue has been fixed and that's a Podman specific issue now ( |
No that test is useless for a bug like this it test actuall completion function that are the same on all platforms so there is no need to duplicate that.
Because we use |
@Luap99 oh ok that's clear now, thanks. Then a new test |
@l0rd am I looking at the right document for unit testing? It seems like
And in the pipeline, that's the only command for unit test. |
@silver886 no, that's not the correct documentation. That's hard to find, but the proper documentation for running podman remote e2e tests is here: |
604cf2e
to
78b109e
Compare
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.
@silver886 thank you very much for the update and the tests. It looks great 👏. We are almost there. I have provided some suggestions, please have a look.
pkg/machine/e2e/help_test.go
Outdated
. "github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("podman completion powershell", func() { |
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.
The command name is usually used in the description. If we add more podman help
tests, they will be added here.
var _ = Describe("podman completion powershell", func() { | |
var _ = Describe("podman help", func() { |
pkg/machine/e2e/help_test.go
Outdated
|
||
var _ = Describe("podman completion powershell", func() { | ||
|
||
It("completion powershell", func() { |
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.
This test will be run on Linux and macOS too. We may specify that this is a Windows only tests so that it doesn't run there but I won't do that as I think there is value in testing it on all OSes.
Instead, I would change the description and adapt the test to ensure that the command matches the string podman
or podman-remote
. I would also add a comment explaining why we are doing this test on the basic command (because command completion doesn't work otherwise) anda link to the issue you are fixing.
It("completion powershell", func() { | |
It("podman usage base command is podman or podman-remote, without extension", func() { |
pkg/machine/e2e/config_help_test.go
Outdated
} | ||
|
||
func (i *helpMachine) buildCmd(m *machineTestBuilder) []string { | ||
cmd := []string{"machine", "info", "--help"} |
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.
cmd := []string{"machine", "info", "--help"} | |
cmd := []string{"help"} |
cmd/podman/root.go
Outdated
// | ||
// It was waiting for a fix in cobra upstream, but since that has not happened yet, | ||
// a fix was implemented in [#24966](https://github.com/containers/podman/pull/24966). |
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.
I don't think that this is necessary and anyway the cobra upstream issue has been fixed.
// | |
// It was waiting for a fix in cobra upstream, but since that has not happened yet, | |
// a fix was implemented in [#24966](https://github.com/containers/podman/pull/24966). |
@l0rd thank you. I have a terrible sense of naming. |
Eh eh, naming is hard :-) Fantastic. Can you please squash the 3 commits into a single one and force push? And please make sure to sign your commit so that the DCO check is passing. |
Signed-off-by: Leo Liu <[email protected]> Add comment In shell completion, there is `.exe` suffix on Windows and this does not provide same experience across platforms, containers#16499 Signed-off-by: Leo Liu <[email protected]> Create unit test for `.exe` suffix removal Signed-off-by: Leo Liu <[email protected]> Update comments Signed-off-by: Leo Liu <[email protected]>
In shell completion, there is
.exe
suffix on Windows and this break several shells.Relates to #16499.
It seems didn't fix at the time but waiting for a fix in cobra.