Take the default when the prune prompt gets an empty line - #422
Merged
Conversation
fmt.Fscanln reports an empty line as "unexpected newline", so pressing enter at the "[y/N]:" prompt exited 1 with that message and the case meant to handle it was unreachable. Read the whole line instead, so the default the prompt offers is the one it takes, and closed input declines rather than erroring. An index read from STDIN consumes the same input the prompt needs, which left it answering EOF. Ask for --yes in that case instead. The prompt writes to the package's stdout writer and reads a new stdin one, which is what lets the tests answer it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fmt.Fscanlnreports an empty line asunexpected newline, so pressing enter at the[y/N]:prompt exited 1 with that message, and thecase "n", "N", "":branch meant to handle it was unreachable. The prompt now reads a whole line, so the default it offers is the one it takes, surrounding whitespace is ignored, and input that is closed without an answer declines rather than failing.An index read from STDIN consumes the very input the prompt needs, leaving it to answer EOF.
desync prune -s store -without--yesnow says so up front rather than failing partway through.The prompt writes to the package's
stdoutwriter and reads from a newstdinone, which is what lets the tests answer it. The confirmation is covered for both the answers that decline and the ones that go ahead, checking the store contents either way.