cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
958 stars 105 forks source link

Broken file attributes after formatting #143

Closed Hsilgos closed 4 years ago

Hsilgos commented 4 years ago

Some of our *.cmake files have +x mod (i.e. they are executable) and after applying of cmake-format they are not executable anymore.

Steps:

  1. Create file test.cmake
  2. Write something which requires formatting.
  3. chmod +x test.cmake

  4. cmake-format -i test.cmake

Result: test.cmake is not executable

Expected: test.cmake is executable

cheshirekow commented 4 years ago

cmake-format doesn't write out over the file it is formatting. It writes to a temp file next to the output file, and then renames over the original file (for --in-place). This way if formatting fails you don't have a corrupt file.

It doesn't currently copy file attributes but that would be easy to add. I'll include it in the next push.

cheshirekow commented 4 years ago

Added in v0.6.2.