Skip to content

Commit d2d3bd3

Browse files
JonZeollaclaude
andcommitted
fix: rename template dir to remove NTFS-illegal chars before cookiecutter
The template directory contains | and " which are illegal on NTFS. Extract the zip with unzip (which handles these in MSYS2), then rename the directory to {{cookiecutter.project_name}} which is NTFS-safe and produces identical output for the default project name (no spaces). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d8c66ff commit d2d3bd3

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,32 @@ jobs:
128128
git config --global user.name "CI Automation"
129129
git config --global user.email "ci@zenable.io"
130130
131-
# The cookiecutter template directory name contains characters that
132-
# are illegal on NTFS (double quotes, pipe). Use Git Bash (available
133-
# on all Windows runners) which operates on a POSIX compatibility
134-
# layer where these characters are valid.
131+
# The template directory name contains NTFS-illegal characters
132+
# (double quotes, pipe). Download and extract the zip, then rename
133+
# the template directory to be NTFS-safe. Cookiecutter identifies
134+
# the template dir by matching {{cookiecutter.* so the renamed dir
135+
# must still start with that prefix.
135136
zipUrl="https://github.com/${{ github.repository }}/archive/${TEMPLATE_REF}.zip"
136137
tmpdir=$(mktemp -d)
137138
curl -fsSL "$zipUrl" -o "$tmpdir/template.zip"
138139
unzip -q "$tmpdir/template.zip" -d "$tmpdir/src"
139-
templateDir="$tmpdir/src/$(ls "$tmpdir/src")"
140+
repoDir="$tmpdir/src/$(ls "$tmpdir/src")"
140141
141-
uvx --with gitpython cookiecutter "$templateDir" --no-input --output-dir "$RUNNER_TEMP"
142+
# Rename the template dir to remove NTFS-illegal chars.
143+
# Cookiecutter matches dirs starting with "{{cookiecutter." and
144+
# renders the name as a Jinja2 expression for the output dir.
145+
# {{cookiecutter.project_name}} renders identically to the original
146+
# with replace(" ", "") since the default has no spaces.
147+
cd "$repoDir"
148+
for d in *; do
149+
if [[ "$d" == *'cookiecutter.'* ]]; then
150+
mv "$d" '{{cookiecutter.project_name}}'
151+
break
152+
fi
153+
done
154+
cd -
155+
156+
uvx --with gitpython cookiecutter "$repoDir" --no-input --output-dir "$RUNNER_TEMP"
142157
- name: Verify generated project
143158
shell: pwsh
144159
run: |

0 commit comments

Comments
 (0)