Skip to content

Take the default when the prune prompt gets an empty line - #422

Merged
folbricht merged 1 commit into
masterfrom
fix-prune-prompt
Sep 3, 2026
Merged

Take the default when the prune prompt gets an empty line#422
folbricht merged 1 commit into
masterfrom
fix-prune-prompt

Conversation

@folbricht

Copy link
Copy Markdown
Owner

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 "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 --yes now says so up front rather than failing partway through.

The prompt writes to the package's stdout writer and reads from a new stdin one, 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.

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.
@folbricht
folbricht merged commit 64fd0dc into master Sep 3, 2026
9 checks passed
@folbricht
folbricht deleted the fix-prune-prompt branch September 3, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant