Skip to content

Allow checking out this repository on Windows #2025

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

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from

Conversation

dscho
Copy link
Member

@dscho dscho commented Jul 6, 2025

Changes

  • Renames a couple of files so that the repository can be checked out on Windows.

Context

Kinda reported here: On Windows, filenames cannot contain certain characters such as colons, question marks, etc. But there are some six hundred plus files in this repository that do contain these characters in their file names.

Luckily, Hugo allows for files to have filenames that do not correspond to their final URL: Simply specify the url attribute in the front matter and use whatever filename your heart desires.

Even more luckily, the automation already adds said url attribute in case the URL contains these special characters.

All I had to do was to rename the files, and then update the script that updates the files in external/book/ whenever the upstream ProGit source truth changes.

Note: Due to the filename restrictions that still apply, even to the output of Hugo in public/, it is still impossible to process the book via Hugo; It will fail thusly:

Start building sites …
hugo v0.147.9-29bdbde19c288d190e889294a862103c6efb70bf+extended windows/amd64 BuildDate=2025-06-23T08:22:20Z VendorInfo=gohugoio

ERROR Alias "/book/de/Los-geht’s-Wozu-Versionskontrolle?.html" contains invalid characters on Windows: : * ? " < > |
Total in 74092 ms
Error: error building site: render: cannot create "/book/de/Los-geht’s-Wozu-Versionskontrolle?.html": Windows filename restriction

This is outside of our control; If you need to build the site locally on Windows and cannot limit it via a sparse checkout to exclude the affected files, you only have the option of using the Windows Subsystem for Linux, otherwise you're out of luck.

dscho added 2 commits July 6, 2025 12:21
On Windows, colons are not allowed in filenames, and neither are
question marks. Let's just rename the files whose filenames contain
colons or question marks (simply removing them, there are no
collisions).

The affected files (all in the ProGit book) already contain `url`
attributes in the front matter, meaning: Hugo will use the correct
filename in the rendered output, and therefore the end result is the
same as before.

This trick was performed by

  git -c core.quotePath=false ls-files |
  grep ':' |
  while read path
  do
    git mv --sparse "$path" "${path/:/}" ||
    break
  done

and

  git -c core.quotePath=false ls-files |
  grep '?' |
  while read path
  do
    git mv --sparse "$path" "${path/\?/}" ||
    break
  done

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
We just fixed the checkout on Windows by renaming files whose names
contain colons or question marks. Let's prevent those filenames (which
are invalid on Windows) from being re-generated in the future.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho self-assigned this Jul 6, 2025
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