Skip to content
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

Add check for illegal Windows filenames #589

Closed
ericfrederich opened this issue Apr 22, 2021 · 9 comments · Fixed by #1031
Closed

Add check for illegal Windows filenames #589

ericfrederich opened this issue Apr 22, 2021 · 9 comments · Fixed by #1031

Comments

@ericfrederich
Copy link
Contributor

ericfrederich commented Apr 22, 2021

There are file and directory names which are legal in Git and most operating systems but illegal in Windows. They should be avoided in case a developer happens to use Windows.

The following names are illegal as bare names as well as with extensions regardless of case for files or directories. For instance CoM6, cOm6.txt, com6.foo.jpg, etc are all illegal. Windows will refuse to create those files if you try to check them out.

From: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Do not use the following reserved names for the name of a file:

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.

ericfrederich added a commit to ericfrederich/pre-commit-hooks that referenced this issue Apr 22, 2021
@asottile
Copy link
Member

seems like a good idea in line with the spirit of the repository! 👍

@theGASK
Copy link

theGASK commented May 12, 2021

i would suggest splitting the check between Win32 and WinNT, even if WinObj does a good job

@asottile
Copy link
Member

@theGASK sorry what?

@tspearconquest
Copy link

Any progress on this?

@ericfrederich
Copy link
Contributor Author

Just needs to be merged. It's a new standalone check.
My opinion should even make it into the default sample config.

@asottile
Copy link
Member

Just needs to be merged

the PR has a bunch of un-addressed feedback

@DanielNoord
Copy link
Contributor

@asottile Would you want somebody to pick up the PR you already reviewed or prefer if somebody worked on the language: fail solution you suggested there?

@asottile
Copy link
Member

the original author seems to not be interested in fixing their PR so yeah I would appreciate a new one -- probably just language: fail since it'll be simpler and faster

@jleclanche
Copy link

+1 on this :) I would also suggest checking for characters which cannot be used on windows, such as :.

By the way this is a problem in WSL which has led to a lot of pain for me in the past. One contributor had committed a file:Zone.Identifier file which is generated due to downloaded files from the web (see microsoft/WSL#4609). This was a HUGE pain to remove as it broke the repository on Windows. I would even suggest explicitly checking for that sort of file, but a hook checking for bad characters such as : would help.

ericfrederich added a commit to ericfrederich/pre-commit-hooks that referenced this issue Mar 26, 2024
ericfrederich added a commit to ericfrederich/pre-commit-hooks that referenced this issue Mar 26, 2024
ericfrederich added a commit to ericfrederich/pre-commit-hooks that referenced this issue Mar 26, 2024
ericfrederich added a commit to ericfrederich/pre-commit-hooks that referenced this issue Apr 10, 2024
ericfrederich added a commit to ericfrederich/pre-commit-hooks that referenced this issue Apr 10, 2024
asottile pushed a commit to ericfrederich/pre-commit-hooks that referenced this issue Apr 14, 2024
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this issue Oct 9, 2024
… (hetznercloud/fleeting-plugin-hetzner!125)

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [pre-commit/pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks) | repository | major | `v4.6.0` -> `v5.0.0` |

Note: The `pre-commit` manager in Renovate is not supported by the `pre-commit` maintainers or community. Please do not report any problems there, instead [create a Discussion in the Renovate repository](https://github.com/renovatebot/renovate/discussions/new) if you have any questions.

---

### Release Notes

<details>
<summary>pre-commit/pre-commit-hooks (pre-commit/pre-commit-hooks)</summary>

### [`v5.0.0`](https://github.com/pre-commit/pre-commit-hooks/releases/tag/v5.0.0): pre-commit-hooks v5.0.0

[Compare Source](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)

##### Features

-   `requirements-txt-fixer`: also remove `pkg_resources==...`.
    -   [#&#8203;850](pre-commit/pre-commit-hooks#850) MR by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;1030](pre-commit/pre-commit-hooks#1030) issue by [@&#8203;ericfrederich](https://github.com/ericfrederich).
-   `check-illegal-windows-names`: new hook!
    -   [#&#8203;1044](pre-commit/pre-commit-hooks#1044) MR by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;589](pre-commit/pre-commit-hooks#589) issue by [@&#8203;ericfrederich](https://github.com/ericfrederich).
    -   [#&#8203;1049](pre-commit/pre-commit-hooks#1049) MR by [@&#8203;Jeffrey-Lim](https://github.com/Jeffrey-Lim).
-   `pretty-format-json`: continue processing even if a file has a json error.
    -   [#&#8203;1039](pre-commit/pre-commit-hooks#1039) MR by [@&#8203;amarvin](https://github.com/amarvin).
    -   [#&#8203;1038](pre-commit/pre-commit-hooks#1038) issue by [@&#8203;amarvin](https://github.com/amarvin).

##### Fixes

-   `destroyed-symlinks`: set `stages` to `[pre-commit, pre-push, manual]`
    -   MR [#&#8203;1085](pre-commit/pre-commit-hooks#1085) by [@&#8203;AdrianDC](https://github.com/AdrianDC).

##### Migrating

-   pre-commit-hooks now requires `pre-commit>=3.2.0`.
-   use non-deprecated names for `stages`.
    -   [#&#8203;1093](pre-commit/pre-commit-hooks#1093) MR by [@&#8203;asottile](https://github.com/asottile).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMTAuMiIsInVwZGF0ZWRJblZlciI6IjM4LjExMC41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants