dotter icon indicating copy to clipboard operation
dotter copied to clipboard

[FEATURE] Read-only rendered files

Open magistau opened this issue 4 years ago • 5 comments
trafficstars

Is your feature request related to a problem? Please describe. Sometimes I forget about dotter and edit files in place (e.g. ~/.config/sway/config instead of ~/.dotter/sway) This causes issues when deploying dotfiles.

Describe the solution you'd like Make the rendered files read-only (like chmod a-w)

Describe alternatives you've considered None

Additional context None

magistau avatar Jan 30 '21 13:01 magistau

So instead of having:

  • edit target file
  • everything "works"
  • dotter warns you next time you run it and suggests --force

You'd like

  • edit target file
  • editor refuses to save

I think it would be a better user experience in that case, but right now Dotter copies the permissions exactly as they are on the source file and I don't want to change it by default. Also, editing the target file is sometimes useful for quickly testing something or for GUI applications that actually edit it when you modify their settings.

I'm open to implementing this as a flag though. Maybe it's about time we had a dotter.toml for these kinds of settings...

SuperCuber avatar Jan 30 '21 14:01 SuperCuber

Would it be possible to not change the permissions of the files, but add the ability to automatically merge changes before deploying? There could also be a merge command. Dotter can print an error if the file has templates. Even better, if the changes don't touch template code, then do the merge. I'm not sure how you would implement this, though. Although, I'm open to helping out after the semester ends.

plmwd avatar Nov 09 '21 23:11 plmwd

Dotter can print an error if the file has templates.

This is actually the only interesting case - in case of a symlink, the filesystem already keeps both locations in sync since they actually are the same file on disk, so nothing needs to be done.

I'm not sure on how to implement this either :P

SuperCuber avatar Nov 10 '21 15:11 SuperCuber

Maybe one possibility is to pre-render template in temp/cache folder then diff the pre-render with the target?

kakawait avatar Jan 02 '22 12:01 kakawait

Maybe one possibility is to pre-render template in temp/cache folder then diff the pre-render with the target?

It seems like a good idea and a pretty simple solution to the problem - this will also help you decide if you want to --force or not


Note to self: This could be done in this code - stick a print_template_diff in case of Changed

Note2: Actually this is more complicated. The Changed comparison is between cache (how I left the file) and target, but diff is between rendered and target... :/ my brain hurts

SuperCuber avatar Jan 02 '22 13:01 SuperCuber