Skip to content

Allow empty file lists with --allow-no-files - #135

Merged
JeffFaer merged 3 commits into
google:mainfrom
rksharma-owg:codex/fix-134-allow-no-files
Nov 2, 2026
Merged

JeffFaer merged 3 commits into
google:mainfrom
rksharma-owg:codex/fix-134-allow-no-files

Conversation

@rksharma-owg

@rksharma-owg rksharma-owg commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Hooks can invoke keep-sorted with an empty file list when a commit only deletes files. Add the opt-in --allow-no-files flag requested in #134 so that an empty invocation can succeed silently. Default no-files rejection, configuration validation and processing of supplied files remain unchanged. The README documents the hook use case.

As requested in review, the tests now isolate Run dispatch with an operation spy. Eight cases verify default rejection, opt-in success without calling the operation, configuration validation, named-file/stdin forwarding, and operation result/error propagation. There is no filesystem or standard-stream orchestration in this test. Existing golden integration tests still exercise the real operations. This review update changes only cmd/cmd_test.go; production code and README are unchanged.

Validation: Go1.23.12 full tests/goldens, vet, build, formatting and repository pre-commit checks pass locally. Two controlled mutations fail the relevant unit case: removing empty-file acceptance, and incorrectly invoking the operation for an enabled empty list. The restored source passes.

Exact-source fork validation passes all four jobs: full tests, build, vet and format on Linux, Windows and macOS, plus Linux pre-commit. All eight unit cases pass on each OS. Tested source a2ca9be5ff7fcc5a2b75a9822274ccd4ea418cf9, current target b225c42a9a8f480d760cf967d1e3a839060b242c, separate workflow revision 4ca6a101833faf0b43c4555d885f09a363bdda56. Fork validation configuration is outside this contribution diff.

Fixes #134.

@MRDGH2821

Copy link
Copy Markdown

Is this ready to be merged?

Comment thread cmd/cmd_test.go Resolved
Comment thread cmd/cmd_test.go Resolved

@JeffFaer JeffFaer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for bearing with me!

@JeffFaer

Copy link
Copy Markdown
Collaborator

@KatrinaHoffert huh, looks like I'm not allowed to approve PRs anymore? I guess I can't say I'm surprised but that is a little bit of a bummer Can you allow the workflows to run on this?

@KatrinaHoffert

Copy link
Copy Markdown
Member

@JeffFaer I can, but let me first see if I can get you added back as a maintainer. Sent a request. Please give that a try and let me know if it doesn't work (as then I'll review myself).

@JeffFaer

JeffFaer commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

It worked!

@JeffFaer
JeffFaer merged commit c426b24 into google:main Nov 2, 2026
11 checks passed
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.

[BUG]: keep-sorted pre-commit hook blocks git commits on file deletions

4 participants