Skip to content

Commit 28d68a3

Browse files
committed
Don't save the _template in the replay file if it looks local
Only save the template in the replay file if it looks remote. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent c28868d commit 28d68a3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cookiecutter/hooks/post_gen_project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ def copy_replay_file() -> None:
152152
# the generated project.
153153
replay_data["cookiecutter"].pop("_output_dir", None)
154154

155+
if template := replay_data["cookiecutter"].get("_template"):
156+
if not template.startswith(("gh:", "git@", "https://")):
157+
print(
158+
f"WARNING: The replay file's `_template` ({template}) doesn't seem "
159+
"to be a remote repository, it won't be saved to avoid storing a "
160+
"local template in the new repository. If this is incorrect, "
161+
f"please add it back manually to {dst}."
162+
)
163+
replay_data["cookiecutter"].pop("_template", None)
164+
155165
with dst.open("w", encoding="utf8") as output_file:
156166
_json.dump(replay_data, output_file, indent=2)
157167
except KeyError as error:

0 commit comments

Comments
 (0)