typos icon indicating copy to clipboard operation
typos copied to clipboard

Checking all files in git index

Open szepeviktor opened this issue 2 years ago • 9 comments

I am a ~~devops person~~ GitHub junky meeting many projects. Sad new is in #779 😢 I need to check every single file in a git repository, not in the filesystem. Today I've learned that Typos ignores dotfiles and dotdirectories even when they are under vcs control.

Tried typos --hidden but that also check .git/* files. Tried typos $(git ls-files) but that has problems with files with whitespaces in the filename.

How to run Typos on all files in git index, not on the filesystem?

szepeviktor avatar Aug 03 '23 23:08 szepeviktor

typos --hidden --exclude=.git/ feels so bad! Like giving Typos a crutch.

szepeviktor avatar Aug 03 '23 23:08 szepeviktor

You can use git ls-files | xargs typos - see my post.

adamchainz avatar Aug 07 '23 20:08 adamchainz

Thank you @adamchainz!

Could it be that this command will have problems with spaces in the filename? https://github.com/szepeviktor/adam-vs-xargs/actions/runs/5789737478/job/15691397394

szepeviktor avatar Aug 07 '23 20:08 szepeviktor

Try git ls-files -z | xargs -0 ls -l

adamchainz avatar Aug 07 '23 20:08 adamchainz

Done 🍏 https://github.com/szepeviktor/adam-vs-xargs/blob/449364e020f5a1144ba04aa2b547203c24c1f408/.github/workflows/blanky.yml#L14

szepeviktor avatar Aug 07 '23 20:08 szepeviktor

@epage Could we use git ls-files -z | xargs -0 -- typos instead of typos . in the action?

szepeviktor avatar Aug 07 '23 20:08 szepeviktor

I've now updated my post to use null byte separators.

adamchainz avatar Aug 07 '23 21:08 adamchainz

Compacted the action down to ~10 lines https://github.com/szepeviktor/byte-level-care/blob/f47f5c28505d14e7aa7a3a1fa0fa605fe3163ee4/.github/workflows/spelling.yml#L38-L49 but I do not want to cook at home!

szepeviktor avatar Aug 07 '23 22:08 szepeviktor

Passing files in will make people hit #347

epage avatar Aug 07 '23 22:08 epage