fix(update): preserve executable bit for new files#2683
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2683 +/- ##
==========================================
+ Coverage 97.19% 97.24% +0.05%
==========================================
Files 60 60
Lines 7237 7299 +62
==========================================
+ Hits 7034 7098 +64
+ Misses 203 201 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e54de87 to
1ff0ae8
Compare
|
Thanks for pointing that out, @sisp. Yes, after looking at #2640, this is essentially the same direction: create an intent-to-add entry for new executable files with I started from #2630 and missed the existing PR, sorry for the duplicate work. #2640 is older and more complete, so I’m happy to close this PR to avoid adding noise. If useful, feel free to reuse anything from the additional non-executable-file regression test here, but otherwise I’ll consider this superseded by #2640 / the larger #2376 direction. |
|
Thanks for checking and confirming! Since #2376 is the better solution, I'm closing this PR to avoid duplicate work. |
Fixes #2630.
When a template update introduces a new executable file in a destination repository with
core.fileMode=false, Git ignores the on-disk executable bit. As a result, the user's latergit addrecords the new file as100644instead of100755.This change handles new executable files in the same executable-bit sync path used for existing files:
core.fileMode=false;Copier first creates an empty intent-to-add index entry, then updates only that entry's mode via
git update-index --cacheinfo. This prepares the executable bit without staging the rendered file contents.Added regression coverage for a template update that introduces a new executable file, verifying that:
100755;git addrecords the file as100755.Also added coverage for new non-executable files with
core.fileMode=false, ensuring Copier leaves them untracked and does not create an unnecessary intent-to-add index entry.Tests run:
pytest -q tests/test_updatediff.py -k "new_files_with_filemode_false or new_non_executable_files" -rsLC_ALL=C pytest -q tests/test_updatediff.py -k "executable_bit or exec_bit or new_non_executable_files" -rsLC_ALL=C pytest -q tests/test_updatediff.py -rsLC_ALL=C pytest -q tests/test_updatediff.py tests/test_copy.py -rsruff format --check copier/_main.py tests/test_updatediff.pyruff check copier/_main.py tests/test_updatediff.py