Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions copier/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,20 @@ def _answers_to_remember(self) -> Mapping[str, Any]:
answers: AnyByStrDict = {}
commit = self.template.commit
src = self.template.url
# Resolve template path to a relative one when possible
if src:
Comment thread
Oscar-SR marked this conversation as resolved.
Outdated
src_path = Path(src)
# Only resolve local relative paths that exist on disk
if not src_path.is_absolute() and src_path.exists():
src_resolved = src_path.resolve()
dst_resolved = self.subproject.local_abspath.resolve()
try:
src = os.path.relpath(
Comment thread
Oscar-SR marked this conversation as resolved.
Outdated
str(src_resolved), str(dst_resolved)
)
except ValueError:
# Fallback for cross-drive paths on Windows
src = str(src_resolved)
for key, value in (("_commit", commit), ("_src_path", src)):
if value is not None:
answers[key] = value
Expand Down