copier icon indicating copy to clipboard operation
copier copied to clipboard

Bool argument is handled as string in 'recopy' operation

Open lhupfeldt opened this issue 1 year ago • 4 comments

Describe the problem

An argument which is correctly handled as bool in copy and update becomes a string in recopy operation.

Template

See #1727 for template

To Reproduce

See #1727 for initial steps

copier recopy -A --data with_internal1=false --data show_internal_test_options=true

The result is:

modified   .copier-answers.yml
@@ -2,5 +2,5 @@
 _commit: 0fa9e2f
 _src_path: ../copier_ignored_arg_bug
 project_name: X
-with_internal1: true
+with_internal1: 'false'
modified   f1.txt
@@ -1 +1 @@
-with_internal1: True
+with_internal1: false

Logs

No response

Expected behavior

The argument declared bool stays a bool

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

Fedora

Copier version

9.3.1

Python version

3.11.8

Installation method

pip+pypi

Additional context

No response

lhupfeldt avatar Aug 09 '24 12:08 lhupfeldt

Log:

 Copying from template version 0.0.0.post1.dev0+0fa9e2f
 identical  .
  conflict  f1.txt
 Overwrite f1.txt? [Y/n] 
  conflict  .copier-answers.yml
 overwrite  .copier-answers.yml

The changes are reported as conflicts even though they are simply changes. There has been no manual change to the generated f1.txt.

lhupfeldt avatar Aug 09 '24 12:08 lhupfeldt

I've seen this with update as well.

lhupfeldt avatar Aug 12 '24 20:08 lhupfeldt

This happens only when -A, --skip-answered is passed as well. The reason is that a new answer is not parsed when -A, --skip-answered is passed and the question has a previously recorded answer:

https://github.com/copier-org/copier/blob/e347f7b06fafd90e807bd5f6c85653d7ba506669/copier/main.py#L482-L484

I think this can be fixed by additionally checking whether results.init contains a new answer. I'll look into it.

sisp avatar Aug 19 '24 14:08 sisp

I've submitted a PR that fixes this problem: #1739

sisp avatar Aug 20 '24 09:08 sisp