Skip to content
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

Bool argument is handled as string in 'recopy' operation #1728

Closed
lhupfeldt opened this issue Aug 9, 2024 · 4 comments · Fixed by #1739
Closed

Bool argument is handled as string in 'recopy' operation #1728

lhupfeldt opened this issue Aug 9, 2024 · 4 comments · Fixed by #1739
Labels
bug triage Trying to make sure if this is valid or not
Milestone

Comments

@lhupfeldt
Copy link

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 lhupfeldt added bug triage Trying to make sure if this is valid or not labels Aug 9, 2024
@lhupfeldt
Copy link
Author

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.

@yajo yajo added this to the Soon milestone Aug 12, 2024
@lhupfeldt
Copy link
Author

I've seen this with update as well.

@sisp
Copy link
Member

sisp commented Aug 19, 2024

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:

copier/copier/main.py

Lines 482 to 484 in e347f7b

# Skip a question when the user already answered it.
if self.skip_answered and var_name in result.last:
continue

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

@sisp
Copy link
Member

sisp commented Aug 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Trying to make sure if this is valid or not
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants